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 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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
  • 1061 views
  • 0 likes
  • 2 in conversation