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);
It's your turn to help shape SAS Innovate 2027. Share your expertise and inspire the SAS community.
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.