Hello,
I want to sort years in column sequentially. For example,
Data have
| id | year |
| 1 | 1998 |
| 1 | 1998 |
| 1 | 1999 |
| 1 | 1999 |
| 1 | 2000 |
| 1 | 2000 |
| 1 | 2000 |
| 1 | 2000 |
| 1 | 2001 |
Data want
| id | year |
| 1 | 1998 |
| 1 | 1999 |
| 1 | 2000 |
| 1 | 2001 |
| 1 | 1998 |
| 1 | 1999 |
| 1 | 2000 |
| 1 | 2000 |
| 1 | 2000 |
Thank you so much!
You'll need to add a variable to indicate the proper order. For example:
data want;
set have;
by id year;
if first.year then order=1;
else order + 1;
run;
Then all you need to do is sort the data:
proc sort data=want;
by id order year;
run;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.