I have the following data:
data have; input id type $ date :mmddyy10.; format type $3. date mmddyy10.; cards; 1 A-2 1/1/2021 1 A-1 1/4/2021 1 A-1 1/20/2021 2 A-1 1/1/2021 2 A-1 1/4/2021 3 A-1 1/1/2021 3 A-2 1/4/2021 4 A-2 1/1/2021 4 A-3 1/4/2021 4 A-1 1/5/2021 5 A-2 2/1/2021
;
I would like to keep only all observations with 10 or more days difference by ID, but if within 10-days then type should be with smallest value's row (see id=1 and type=A-1; also id=4 and type=A-1) even the date was higher than the previous date, see wanted data:
ID
TYPE
DATE
1
A-1
1/4/2021
1
A-1
1/20/2021
2
A-1
1/1/2021
3
A-1
1/1/2021
4
A-1
1/5/2021
5
A-2
2/1/2021
How can I accomplish this? Thank you.
... View more