SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

Extracting by minimum date for the group

Reply
New Contributor
Posts: 4

Extracting by minimum date for the group

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
PROC Star
Posts: 7,480

Re: Extracting by minimum date for the group

Posted in reply to radhikaa4

just instruct your code to do it:

 

 

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

Art, CEO, AnalystFinder.com

PROC Star
Posts: 326

Re: Extracting by minimum date for the group

Posted in reply to radhikaa4

something like should work

proc sql;
select * from have
group by master_id
having date =min(date);
Ask a Question
Discussion stats
  • 2 replies
  • 149 views
  • 0 likes
  • 3 in conversation