- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Dear, I have not been able to solve the following problem, hopefully you can help me. I have an ID with associated dates, and I need to sort the data by ID, descending date and count these records one by one. for instance: the table I have
and this is the result that I should get.
thanks you.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
proc sort data=have;
by ID descending date;
run;
data want;
set have;
by id descending date;
if first.id then number_order=1;
else number_order+1;
run;
https://stats.idre.ucla.edu/sas/faq/how-can-i-create-an-enumeration-variable-by-groups/
@Andres_Fuentes1 wrote:
Dear, I have not been able to solve the following problem, hopefully you can help me. I have an ID with associated dates, and I need to sort the data by ID, descending date and count these records one by one. for instance: the table I have
and this is the result that I should get.
thanks you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
proc sort data=have;
by ID descending date;
run;
data want;
set have;
by id descending date;
if first.id then number_order=1;
else number_order+1;
run;
https://stats.idre.ucla.edu/sas/faq/how-can-i-create-an-enumeration-variable-by-groups/
@Andres_Fuentes1 wrote:
Dear, I have not been able to solve the following problem, hopefully you can help me. I have an ID with associated dates, and I need to sort the data by ID, descending date and count these records one by one. for instance: the table I have
and this is the result that I should get.
thanks you.