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

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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