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);
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
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.