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

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

 

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

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;

View solution in original post

2 REPLIES 2
Kurt_Bremser
Super User

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;
amanjot_42
Fluorite | Level 6

Thank you so much!

 

It worked perfectly

 

Regards

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 2 replies
  • 851 views
  • 0 likes
  • 2 in conversation