Hi guys,
I am trying to run a regression on daily returns for every fiscal year. But the minimum number of observations for each fiscal year required for a firm are 200. If there are not enough observations (less than 200), I would like to drop that fiscal year from my regression analysis. Can you please help me in this regard. The sample ranges from the fiscal year - 2013 to 2019 daily observations for different firms. My regression model is to regress stock returns against the market returns for every fiscal year (minimum number of daily returns required to be 200) and for every firm.
Firm_ID date stock_returns market_returns fiscal_year
11 02/04/2013 7 1.5 2014
11 03/04/2013 9 -10 2014
.............
12 02/04/2013 5 3.5 2014
12 03/04/2013 4 -1 2014
............
13 02/04/2013 6 0.9 2014
13 03/04/2013 4 -1 2014
............
Regards,
Amanjot
Sort by firm and year, and then run a double do loop:
proc sort data=have;
by firm_id fiscal_year;
run;
data want;
count = 0;
do until (last.fiscal_year);
set have;
by firm_id fiscal_year;
count + 1;
end;
do until (last.fiscal_year);
set have;
by firm_id fiscal_year;
if count ge 200 then output;
end;
drop count;
run;
Sort by firm and year, and then run a double do loop:
proc sort data=have;
by firm_id fiscal_year;
run;
data want;
count = 0;
do until (last.fiscal_year);
set have;
by firm_id fiscal_year;
count + 1;
end;
do until (last.fiscal_year);
set have;
by firm_id fiscal_year;
if count ge 200 then output;
end;
drop count;
run;
Thank you so much!
It worked perfectly
Regards
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.