Hi guys,
suppose to have the following:
data DB;
input ID :$20. Admission :date09. Discharge :date09. Index;
format Admission date9. Discharge date9.;
cards;
0001 13JAN2017 25JAN2017 0
0001 13JAN2017 25JAN2017 1
0001 22FEB2018 03MAR2018 1
0001 30JAN2019 04MAR2019 0
0002 01DEC2018 14DEC2018 0
0002 25DEC2018 02JAN2019 0
0002 25NOV2020 03DEC2020 1
0003 09JAN2016 25JAN2016 1
0003 29JAN2018 12FEB2018 0
...;
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 13JAN2017 25JAN2017 0
0001 13JAN2017 25JAN2017 1
0001 22FEB2018 03MAR2018 0
0001 30JAN2019 04MAR2019 0
0002 01DEC2018 14DEC2018 0
0002 25DEC2018 02JAN2019 0
0002 25NOV2020 03DEC2020 1
0003 09JAN2016 25JAN2016 1
0003 29JAN2018 12FEB2018 0
...;
In other words let's consider ID = 0001.
I would like:
1) if Index = 1 for more than a date (adm-disch) for the same patient it will be 1 if it is the first date otherwise 0. This will regard only cases where Index = 1. For pts 0001 for example, for the same date (13JAN2017 25JAN2017
) Index can be "0" or "1". If it is 0 nothing will happen and the change will regard the row where dates are 13JAN2017 - 25JAN2017.
Thank you in advance