BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
shafayat
Calcite | Level 5

Can anyone please give me some clue how I can keep the last observation of "EACH" year of a specific company in a weekly panel data in order to annualize it? 

 

If I create year variable from the date and use last.year command, it only retains the last observation for the company, NOT the last for "EACH" year.

 

I tried sorting the data by year and then permno instead of by permno and then year, but had no luck; it then keeps only 1 observation from each year and deletes other years' data for other companies. 

 

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

1) Create a year variable

2) Sort by permno and year

3) then, in a data step do

 

data newData;

set myData; by permno year;

if first.year or last.year;

run;

PG

View solution in original post

3 REPLIES 3
PGStats
Opal | Level 21

1) Create a year variable

2) Sort by permno and year

3) then, in a data step do

 

data newData;

set myData; by permno year;

if first.year or last.year;

run;

PG
Astounding
PROC Star

You will have to show your work.  It is entirely possible that you are using the correct tools, but using them incorrectly.  So post the program that isn't working.

shafayat
Calcite | Level 5
This is what I was doing. I was puzzled why it did not work. I don’t even know what changed but after quite a while it started working. Thanks though.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

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
  • 3 replies
  • 1248 views
  • 0 likes
  • 3 in conversation