Hello. Here's the sample dataset and I am trying to extract only first occurence of the group BY date
MASTER_ID | value | date |
1 | 105 | 7/7/2003 |
1 | 102 | 7/19/2003 |
2 | 100.5 | 7/27/2001 |
2 | 107 | 7/28/2001 |
2 | 108 | 7/29/2001 |
3 | 100.5 | 6/20/2002 |
3 | 103.5 | 6/24/2002 |
4 | 102.5 | 7/19/2001 |
4 | 105 | 7/20/2001 |
4 | 102.5 | 7/21/2001 |
Final output:
MASTER_ID | value | date |
1 | 105 | 7/7/2003 |
2 | 100.5 | 7/27/2001 |
3 | 100.5 | 6/20/2002 |
4 | 102.5 | 7/19/2001 |
just instruct your code to do it:
data want; set have; by master_id; if first.master_id; run;
Art, CEO, AnalystFinder.com
something like should work
proc sql; select * from have group by master_id having date =min(date);
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.
Find more tutorials on the SAS Users YouTube channel.