BookmarkSubscribeRSS Feed
omega1983
Calcite | Level 5

proc sql;

create table DueDt as

select a.ln_no,a.pmt_am,a.pmt_due_dt

from payment_tran   a

left join DSM                 b

  on a.ln_no=b.ln_no

  where a.rec_chng_cd in ('A','C')

order by a.ln_no,a.pmt_due_dt;

quit;

Because this hits the entire payment_tran table, this dataset produces 50mllion records.  I want only the last transaction based on the ln_no and pmt_due_dt.  If it were a datastep I would know how to write this.  Because I am joining this to another datastep (DSM) the only way I know to do this is through a proc sql.  I want to create the last payment due date table and join it to the DSM table.  Any ideas on how to make this query select only the last records using a proc sql statement

1 REPLY 1
Ksharp
Super User

You'd better post some sample data and output you need. That would be better . from your description It seems that you need a having clause.

group by ln_no

   having pmt_due_dt=max( pmt_due_dt) ;



Ksharp

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 1035 views
  • 0 likes
  • 2 in conversation