Help using Base SAS procedures

proc sql statement to pull last due date

Reply
Contributor
Posts: 59

proc sql statement to pull last due date

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

Super User
Posts: 9,671

Re: proc sql statement to pull last due date

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

Ask a Question
Discussion stats
  • 1 reply
  • 161 views
  • 0 likes
  • 2 in conversation