/*****************************************************************/
/* outcomes: */
/* */
/* 022.MI/stroke/death/HF - AT, ITT */
/*****************************************************************/
data lastdate_itt(rename=(lastdate = lastdate_itt));
set out.dm_cohort(rename=(enr_end = enddt));
end_data = '31Dec2019'd;
lastdate = min( deathdt, enddt,end_data);
keep patid indexdt class lastdate deathdt;
run;
data lastdate_at(rename=(lastdate= lastdate_at));
set out.lastdate;
keep patid indexdt class lastdate;
run;
data ids;
merge lastdate_itt
lastdate_at;
by patid;
keep patid indexdt class lastdate_itt lastdate_at deathdt;
run;
%macro hosp;
%do year = 2012 %to 2019;
proc sql;
create table dx&year(keep=patid indexdt admit_date dx enc_type dx_type pdx) as
select * from in.diagnosis&year(keep= patid admit_date dx enc_type dx_type pdx ) dx,
ids
where ids.patid = dx.patid and
admit_date > indexdt;
quit;
proc sort nodup data = dx&year;
by patid indexdt admit_date dx;
run;
%end;
data all_dx(rename=(dx_type = dx_codetype));
set dx2019
%do year = 2012 %to 2018;
dx&year
%end;
;
run;
%mend;
%hosp;
data dx09 dx10;
set all_dx;
if enc_type = "IP" and pdx = 'P';
if dx_codetype = '09' then output dx09;
if dx_codetype = '10' then output dx10;
keep patid indexdt admit_date dx ;
run;
proc format;
value $dxfmt
'G450' ,
'G458' ,
'I609' ,
'I619' ,
'I6200' ,
'I621' ,
'I629' ,
'I63019',
'I63139',
'I6320' ,
'I6322' ,
'I6330' ,
'I6340' ,
'I6350' ,
'I6359' ,
'I6509' ,
'I651' ,
'I6529' ,