After years of reading the forum, I'm finally making my first post for something that is stumping me and there must be a solution. I have the dataset below: data have;
input id:32. event:$10. date:DATE9. reason:$8.;
format date DATE9.;
label id="id" event="event" date="date" reason="reason";
datalines;
1 entered 01JAN2020 .
1 discharged 01FEB2020 finished
2 entered 05MAR2021 .
2 discharged 15JUL2021 left
2 entered 20SEP2021 .
3 entered 05FEB2020 .
3 discharged 05MAR2020 finished
3 entered 11APR2021 .
3 discharged 01SEP2021 finished
4 entered 01DEC2018 .
4 discharged 01FEB2019 finished
4 entered 05MAR2019 .
4 discharged 06DEC2020 left
4 entered 03APR2021 .
;
run; I would like to transpose this dataset to create the following: Essentially the solution will need to look within each ID, find each pair of consecutive dates, and then transpose the data. If an id has an odd number of records, then there would be a "last" row for that id in the new dataset that is missing for non-present pair in the original data (see ids 2 and 4 in the image above). Using SAS 9.4 here. Any help is greatly appreciated.
... View more