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.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
Register now!
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.