BookmarkSubscribeRSS Feed
radhikaa4
Calcite | Level 5

Hello. Here's the sample dataset and I am trying to extract only first occurence of the group BY date

 

MASTER_IDvaluedate
11057/7/2003
11027/19/2003
2100.57/27/2001
21077/28/2001
21087/29/2001
3100.56/20/2002
3103.56/24/2002
4102.57/19/2001
41057/20/2001
4102.57/21/2001

 

Final output:

 

MASTER_IDvaluedate
11057/7/2003
2100.57/27/2001
3100.56/20/2002
4102.57/19/2001
2 REPLIES 2
art297
Opal | Level 21

just instruct your code to do it:

 

 

data want;
  set have;
  by master_id;
  if first.master_id;
run;

Art, CEO, AnalystFinder.com

kiranv_
Rhodochrosite | Level 12

something like should work

proc sql;
select * from have
group by master_id
having date =min(date);

sas-innovate-white.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.

 

Early bird rate extended! Save $200 when you sign up by March 31.

Register now!

How to connect to databases in SAS Viya

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.

Discussion stats
  • 2 replies
  • 2214 views
  • 0 likes
  • 3 in conversation