Hi,
I have a dataset
ID Sub_ID Date
1 23 2020-06-01
1 24 2019-06-02
2 29 2015-05-04
2 33 2012-06-09
2 31 2014-09-09
I want to select the earliest Date of the SubID.
ID SubID Date
Can I do this is SAS? thanks in advance.
proc summary data=have nway; class id; var date; output out=want minid(date(sub_id))=subid min=; run;
And another:
Proc sort data=have; by id date; run; data want; set have; by id; if first.id; run;
When you use By processing in a data step SAS provides automatic variables that indicate whether a specific record is the first or last of a by group.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Submit your idea!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.