Suppose I have the following:
data DB;
input ID :$20. Admission :date09. Discharge :date09. Index;
format Admission date9. Discharge date9.;
cards;
0001 13JAN2015 20JAN2015 1
0001 21FEB2015 31DEC2015 1
0001 01MAR2018 30SEP2018 .
0002 01JAN2015 31MAR2015 1
0002 01MAY2015 31OCT2015 1
0003 08FEB2014 10MAR2014 1
0004 04MAY2016 10MAY2016 1
0004 13JUN2016 15NOV2016 1
0004 09DEC2016 31DEC2016 1
;
Is there a way to get the following?
data DB1;
input ID :$20. Admission :date09. Discharge :date09. Index;
format Admission date9. Discharge date9.;
cards;
0001 13JAN2015 20JAN2015 1
0001 21FEB2015 31DEC2015 .
0001 01MAR2018 30SEP2018 .
0002 01JAN2015 31MAR2015 1
0002 01MAY2015 31OCT2015 .
0003 08FEB2014 10MAR2014 1
0004 04MAY2016 10MAY2016 1
0004 13JUN2016 15NOV2016 .
0004 09DEC2016 31DEC2016 .
;
Meaning: if there are repeated Index = 1 for a patient only the first will be retained and the others should be set to missing.
data want;
set DB;
by ID;
if not first.ID then Index = .;
run;