Hello everyone.
I have panel data, and I have some individuals who have multiple observations in the same year.
What I want to do is that I want to keep the last observation of those individuals with multiple observations in the same year.
Visually, I want something like this… (I thought this would show better what I wanna do)
Id data year -> Id data year
1 2 2009 1 3 2009
1 3 2009 1 2 2010
1 2 2010 2 1 2009
2 1 2009 2 3 2010
2 2 2010
2 3 2010
I was trying to use command like: "Data …. ; Set ….; by ID year; if last.ID; run;", but this would only leave last observation of the individual of the last year (assuming that I sorted by ID and year) and erase the previous year. I was wondering if you have a suggestion or idea to this issue..
Thank you very much for your help!
Almost there, assuming correct sort order:
Data …. ; Set ….; by ID year; if last.Year; run;",
Almost there, assuming correct sort order:
Data …. ; Set ….; by ID year; if last.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!
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.