%let Obs_ = Max ;
options FormChar='|----|+|---+=|#/\*' ;
ods noptitle; proc format;
value indexEvent 0 = '0: No AMI index' 1 = '1: AMI index' ;
value readmit 0 = '0: No AMI readmit' 1 = '1: AMI readmit' ;
run;
/* Identify AMI index events */
Title "1 : Index Admissions" ;
data nrd_2014_indexEvents ReadmCandidates ( drop=DISCWT LOS NRD_STRATUM IndexEvent ) ;
set nrd.nrd_2014_core ( obs= &obs_ keep= HOSP_NRD KEY_NRD DX1 DISCWT NRD_STRATUM
AGE DMONTH DIED LOS NRD_VISITLINK
NRD_DAYSTOEVENT DXCCS1 PRCCS: ) ;
attrib IndexEvent length=3 label='AMI index event' ;
IndexEvent = 0 ;
if '41000' le DX1 le '41091' and substr( DX1, 5, 1 ) ne '2'
and AGE ge 18
and 1 le DMONTH le 11
and DIED eq 0
and not missing(LOS) then IndexEvent = 1;
drop DX1 AGE DMONTH DIED;
* Retain index events only ;
if IndexEvent = 1 then output nrd_2014_indexEvents;
output ReadmCandidates ;
run;
Title "2 : 30-day All-Cause Readmission Events" ; /* Select all readmissions within 30 days */
proc sql ;
create table readmissionsAll as select i.HOSP_NRD as HOSP_NRD_Index, i.KEY_NRD as KEY_NRD_Index ,
r.* from nrd_2014_indexEvents i /* Index Events */
inner join ReadmCandidates r /* Readmissions */
on i.NRD_VISITLINK = r.NRD_VISITLINK /* Link patients */
and i.KEY_NRD ne r.KEY_NRD /* Not a self join */
and r.NRD_DAYSTOEVENT - ( i.NRD_DAYSTOEVENT + i.LOS ) between 0 and 30 and i.indexEvent = 1
order by i.HOSP_NRD, i.KEY_NRD, r.NRD_DAYSTOEVENT; /* Sort by date */
quit ;
/* Identify closest readmission if there are multiple readmission events */
data readmissionsClosest;
set readmissionsAll ( rename=(HOSP_NRD=HOSP_NRD_Readmit
HOSP_NRD_Index=HOSP_NRD
KEY_NRD = KEY_NRD_Readmit
KEY_NRD_Index=KEY_NRD)) ;
by HOSP_NRD KEY_NRD ;
if first.KEY_NRD ;
run;
/* Merge readmissions and index events */
data readmissions_sql ;
merge nrd_2014_indexEvents ( drop=DXCCS1 PRCCS: )
readmissionsClosest ( in=inR rename=( NRD_DAYSTOEVENT=DaysToReadmission )
drop=NRD_VisitLink KEY_NRD_Readmit ) ;
by HOSP_NRD KEY_NRD ;
attrib Readmit length = 3 label='Readmission within 30 days (0/1)' ;
Readmit = inR ;
label DaysToReadmission = 'Readmission date';
run ;
/* Augment the index subset with hospital dummy records */
data combined ;
set readmissions_sql NRD.NRD_2014_HOSPITAL (in = inhosp KEEP = HOSP_NRD NRD_STRATUM ) ;
attrib InSubset length = 3 label = 'In Subset' ;
InSubset = 1 ;
if inhosp then do; * Assign a value outside the subset ;
InSubset = 0 ; * Assign a valid weight ;
DISCWT = 1 ; * Set analysis variables to zero ;
IndexEvent = 0 ;
Readmit = 0 ;
end ;
run;
/* Tabulate (unweighted) index and readmission events */ proc freq data = combined ; tables InSubset*IndexEvent * Readmit / list missing ; format indexEvent indexEvent. readmit readmit. ; run ; Title "3 : National Readmission Rates" ; /* National estimates based on NRD design */ /* Specify the sampling design with sampling weights DISCWT, */ /* hospital clusters HOSP_NRD, and stratification NRD_STRATUM */ proc surveymeans data= combined sumwgt sum mean ; cluster HOSP_NRD ; strata NRD_STRATUM ; weight DISCWT ; var Readmit ; /* Subset on index events */ domain InSubset*IndexEvent ; ods output domain = readmissionRates ; format IndexEvent indexEvent. ; run ;
I need help to understand the output files from this code
Thanks