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) 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;
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;
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.
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.
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.