BookmarkSubscribeRSS Feed
Q1983
Lapis Lazuli | Level 10

data test(keep=ln tpr_date);

set test1;

by ln_no;

if last.ln_no;

run;

If I had this output prior to running the above sas script it looks like this

ln                              tpr_date

1                              09/15/2013

1                              10/15/2013

2                              06/15/2014

2                              06/22/2013

2                              06/22/2013

After running the program I would get this

ln                              tpr_date

1                              10/15/2013

2                              06/22/2013

However I would miss the unique value or

2                              06/15/2014

because 2 is the last.ln in the series. I would want this output

ln                              tpr_date

1                              10/15/2013

2                              06/15/2014

2                              06/22/2013

In this case both the ln and tpr_date need to capture the last unique values.  Any ideas here???

2 REPLIES 2
Reeza
Super User

Why are you excluding the first record then? It appears to be unique.

data test(keep=ln tpr_date);

set test1;

by ln_no tpr_date;

if last.tpr_date;

run;

ballardw
Super User

Does this do what you want?

Proc Sql;

     Create table test as

     Select Distinct Ln_no, tpr_date

     from test1;

quit;

But you really need to expand on what you mean by "Unique" if you exclude the first record.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 2 replies
  • 660 views
  • 0 likes
  • 3 in conversation