Hi guys,
suppose to have the following:
data have;
input ID $ (Start End) (:date.) Place $;
format start end date9.;
cards;
0001 13JAN2015 20JAN2015 0
0001 21JAN2015 31DEC2015 1
0001 01JAN2018 31DEC2018 0
0001 01JAN2019 31DEC2019 1
0002 01JAN2015 31DEC2015 1
0002 01JAN2019 31OCT2019 0
0002 01NOV2019 31DEC2020 0
;
Is there a way to add two variables (with 1 = yes, 0= no): one indicating the first date the patient has Place = 1 ever in his life and another indicating the first date the patient has Place = 0 ever in his life?
Desired output:
data have;
input ID $ (Start End) (:date.) Place First_1 First_0 $;
format start end date9.;
cards;
0001 13JAN2015 20JAN2015 0 0 1
0001 21JAN2015 31DEC2015 1 1 0
0001 01JAN2018 31DEC2018 0 0 0
0001 01JAN2019 31DEC2019 1 0 0
0002 01JAN2015 31DEC2015 1 1 0
0002 01JAN2019 31OCT2019 0 0 1
0002 01NOV2019 31DEC2020 0 0 0
;
Thank you in advance