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.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: