BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
TurnTheBacon
Fluorite | Level 6

I need to create a data set that list the last dekning_sk for each distinct avtale_sk from the following source data set:

So, the output data set should say:

Avtale_skDekning_sk
1145
3122
4145
6122
9122
12118
13167
15167

etc...

What kind of user written code would produce this kind of result? Either DATA STEP or PROC SQL would be fine.

Thanks for your time.

1 ACCEPTED SOLUTION

Accepted Solutions
Linlin
Lapis Lazuli | Level 10

How did you get 121 when avtale_sk=3 ? why not 122?

try the modified one:

data want;

  set have;

   by avtale_sk notsorted;

   if last.avtale_sk;

run;

View solution in original post

5 REPLIES 5
Linlin
Lapis Lazuli | Level 10

try:

data want;

  set have;

   by avtale_sk dekning_sk notsorted;

   if last.dekning_sk;

run;

TurnTheBacon
Fluorite | Level 6

Thanks for the suggestion, but as far as I can tell the output data set looks exactly the same.

Linlin
Lapis Lazuli | Level 10

How did you get 121 when avtale_sk=3 ? why not 122?

try the modified one:

data want;

  set have;

   by avtale_sk notsorted;

   if last.avtale_sk;

run;

TurnTheBacon
Fluorite | Level 6

I'm very sorry, that was a typo. I should have been more vigilant. It's been corrected now.

TurnTheBacon
Fluorite | Level 6

Perfect, thank you very much Linlin. Smiley Happy

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!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 5 replies
  • 812 views
  • 0 likes
  • 2 in conversation