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

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!

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Almost there, assuming correct sort order:

Data …. ;   Set ….;  by ID year;   if last.Year; run;",

View solution in original post

2 REPLIES 2
ballardw
Super User

Almost there, assuming correct sort order:

Data …. ;   Set ….;  by ID year;   if last.Year; run;",

master_kim
Fluorite | Level 6
thank you very much! that was a perfect answer!

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 285 views
  • 1 like
  • 2 in conversation