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-2024.png

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.

 

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
  • 1897 views
  • 0 likes
  • 3 in conversation