libname save 'sasdata'; data dnase; infile 'data.dnase'; input id 1-4 inst 5-7 rx 9 @11 entry_dt date7. +1 end_dt date7. fev 5.1 +1 ivstart date7. +1 ivstop date7. ; format entry_dt end_dt ivstart ivstop date7.; * To make coefficients be about the same size, divide fev by 10; fev = fev/10; proc sort data=dnase; by id ivstart; * make the start/stop data set, the one where people are risk free * for 6 days after the exacerbation; * adding time2 and status to the retain statement just makes the * variables have a "nice" order in the output data set; * The "gap" variable is the amount of time off study before starting the * current risk period; data dnase1; set dnase; by id; keep id inst rx time1 time2 status fev enum; keep gap; retain time1 time2 status enum gap; if (first.id=1) then do; time1=0; enum=1; gap =.; end; if (ivstart ne .) then do; time2 = ivstart - entry_dt; status =1; if (time2 > time1) then do; output; enum = enum +1; end; gap = ( 6 + ivstop - ivstart); time1 = 6 + ivstop - entry_dt; end; if (last.id=1) then do; time2 = end_dt - entry_dt; status=0; if (time2 > time1) then output; end; data save.dnase1; set dnase1; by id; if (enum>3) then enum3=3; else enum3=enum; rx1 = rx * (enum=1); fev1 = fev*(enum=1); rx2 = rx * (enum=2); fev2 = fev*(enum=2); rx3 = rx * (enum>2); fev3 = fev*(enum>2); /* ** Now for the WLW data set */ data temp1; set save.dnase1; if (enum=1); data temp2; set save.dnase1; if (enum <3); if (enum <2) then status=0; enum=2; data temp3; set save.dnase1; if (enum <4); if (enum <3) then status=0; enum=3; data temp4; set save.dnase1; if (enum <5); if (enum <4) then status=0; enum=4; data temp5; set save.dnase1; if (enum <5) then status=0; enum=5; data save.dnase2; set temp1 temp2 temp3 temp4 temp5; by id; drop gap; if (enum >3) then enum3=3; else enum3=enum; rx1 = rx * (enum=1); fev1 = fev*(enum=1); rx2 = rx * (enum=2); fev2 = fev*(enum=2); rx3 = rx * (enum>2); fev3 = fev*(enum>2);