DATA Step, Macro, Functions and more

Proc SQL query - Select Minimum Record

Reply
Contributor scb
Contributor
Posts: 50

Proc SQL query - Select Minimum Record

[ Edited ]

dataset a

 

Date           RefNo      Amount

01Jun16     ABC        1000

02Jun16     ABC        1000

03Jun16     ABC        1000

01Jan16     VCV         2100

02Jan16     VCV         2100

03Jan16     VCV         2100

.......etc

 

 

May I know how to get the following dataset using proc sql? I need the minumum date record for each RefNo.

 

Date           RefNo      Amount

01Jun16     ABC        1000

01Jan16     VCV         2100

 

Thanks.

Super User
Posts: 17,963

Re: Proc SQL query - Select Minimum Record

 

proc sql;
create table want as
select *
from have
group by refno
having date=min(date);
quit;

 

You can filter your dataset based on the HAVING clause. 

Ask a Question
Discussion stats
  • 1 reply
  • 154 views
  • 1 like
  • 2 in conversation