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_sk | Dekning_sk |
---|---|
1 | 145 |
3 | 122 |
4 | 145 |
6 | 122 |
9 | 122 |
12 | 118 |
13 | 167 |
15 | 167 |
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.
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;
try:
data want;
set have;
by avtale_sk dekning_sk notsorted;
if last.dekning_sk;
run;
Thanks for the suggestion, but as far as I can tell the output data set looks exactly the same.
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;
I'm very sorry, that was a typo. I should have been more vigilant. It's been corrected now.
Perfect, thank you very much Linlin.
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!
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.