/**********************************************************************************************************************/ /* comorbidity.input.file.example.sas */ /* Last updated: 3/9/2017 */ /**********************************************************************************************************************/ /* This SAS program is one example of how to build an input file for the comorobidity macro. */ /* It can be used as a template for your program, depending on which files and variables you have. */ /* SAS date variables are created for the diagnosis date, start & end of the comorbidity window, and the claim date. */ /* Diagnosis and surgical procedure variables are renamed so that they are mostly the same across claims files. */ /* All unnecessary variables are dropped, for better efficiency, and the claims files are "set" together. */ /* Then, only the claims within the window (+/- 30 days) are selected out of all claims for the patients in PEDSF. */ /**********************************************************************************************************************/ data PEDSF; set PEDSF(keep=patient_id yrdx1 modx1); dx_date = mdy(modx1,1,yrdx1); start_date = mdy(modx1,1,yrdx1-1); /* first day of the month a year before diagnosis */ end_date = mdy(modx1,1,yrdx1)-1; /* last day of the month before diagnosis */ format dx_date start_date end_date mmddyy10.; label dx_date = 'Date of diagnosis' start_date = 'One year before date of diagnosis' end_date = 'Last day before month of diagnosis' ; run; data Claims; length dgn_cd1-dgn_cd25 $7. srgcde1-srgcde25 $4.; set MEDPAR(in=M keep=patient_id adm_m adm_d adm_y los admdxcde dgn_cd1-dgn_cd25 srgcde1-srgcde25 rename=(adm_m=from_dtm adm_d=from_dtd adm_y=from_dty) ) OUTPAT(in=O keep=patient_id from_dtm from_dtd from_dty dgn_cd1-dgn_cd25 prcdr_cd1-prcdr_cd13 rename=(prcdr_cd1-prcdr_cd13=srgcde1-srgcde13) ) NCH(in=N keep=patient_id from_dtm from_dtd from_dty linediag pdgns_cd dgn_cd1-dgn_cd12 rename=(linediag=dgn_cd13 pdgns_cd=dgn_cd14) ) ; if M then filetype = "M"; else if O then filetype = "O"; else if N then filetype = "N"; claim_date = mdy(from_dtm,from_dtd,from_dty); drop from_dtm from_dtd from_dty; format claim_date mmddyy10.; label claim_date = 'Date of claim'; run; proc sql; create table Claims as select * from Claims as c, PEDSF as p where (c.patient_id=p.patient_id) and ( (p.start_date-30)<=c.claim_date<=(p.end_date+30) ) order by c.patient_id, c.claim_date; quit; %include 'charlson.comorbidity.macro.sas'; %COMORB(Claims,patient_id,start_date,end_date,claim_date,filetype,los,admdxcde dgn_cd1-dgn_cd25,srgcde1-srgcde25,R,Comorb);