Hi SAS Pros,
I have a dataset like showed below.
data Have;
input ID first_date :mmddyy10. last_date :mmddyy10. edu class;
format first_date mmddyy10.;
format last_date mmddyy10.;
datalines;
1 02-01-2015 02-01-2015 3 3
1 02-01-2015 02-12-2015 3 1
1 02-01-2015 02-16-2015 3 3
1 02-01-2015 03-01-2015 3 3
1 08-20-2015 09-01-2015 3 3
1 10-06-2015 10-09-2015 2 1
2 10-19-2017 10-19-2017 1 1
2 10-19-2017 10-21-2017 3 1
2 10-19-2017 11-05-2017 2 2
2 10-19-2017 11-11-2017 1 1
2 10-19-2017 12-22-2017 1 1
2 12-25-2017 12-25-2017 3 2
;
run;
I would like to recode the last dates if the records under the same ID match on ID, first_date, edu, and class, with only last dates are different. One of these set of records has a first date and last date are the same (i.e. the first record for each ID). The I would like to enter the date of the record with same first and last dates (i.e. 02-01-2015 for ID=1 and 10-19-2017 for ID=2) for the last dates for those records match on ID, first_date, edu, and class under the same ID.
If the records under the same ID are different in any of ID, first_date, edu, and class, then just leave as them own, regardless first date is different or the same as the last date.
The Want data is also post below.
1 02-01-2015 02-01-2015 3 3
1 02-01-2015 02-12-2015 3 1
1 02-01-2015 02-01-2015 3 3
1 02-01-2015 02-01-2015 3 3
1 08-20-2015 09-01-2015 3 3
1 10-06-2015 10-09-2015 2 1
2 10-19-2017 10-19-2017 1 1
2 10-19-2017 10-21-2017 3 1
2 10-19-2017 11-05-2017 2 2
2 10-19-2017 10-19-2017 1 1
2 10-19-2017 10-19-2017 1 1
2 12-25-2017 12-25-2017 3 2
Thank you very much for any help!
Best regards,
C
... View more