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-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1839 views
  • 0 likes
  • 3 in conversation