Help using Base SAS procedures

Annual regressions is it possible?

Posts: 21

Annual regressions is it possible?


I am using the standard OLS code and wish to have a look at the significance of the independent (income) on the dependent (firmvalue) on a yearly basis.

Currently I am subsetting my sample by year and running the regression. This is a long process as I have 60+ years...So I would like to ask whether it is possible to create a code to automatically do this for me?

So that the output would have the year, the coefficient and significance of income? Basically firm value is my dependent and I have one independent variable income.

My data is attached below. If anyone knows how to do this pls help

Esteemed Advisor
Posts: 5,541

Re: Annual regressions is it possible?

There is only one observation per year in your data. How can you be subsetting by year? - PG

Posts: 21

Re: Annual regressions is it possible?

Easy I create a new db with only that specific year. Keep in mind this is only a sample of my data.

Trusted Advisor
Posts: 1,345

Re: Annual regressions is it possible?

Then you would have better demontrated your problem by giving us a sample of just a few years, but each year with several companies.  Remember, your question was about the significance of predictors on a yearly basis - which I understand to mean you want to estimate regressions for each year..

But given what I do understand you could do this:

proc sort data=have  out=need;

   by year;


proc reg data=need;

  by year;

  model y=x1 x2;


Using the "BY" statement in the regression proc tells it that the input data is coming in already grouped by year, and to run the PROC REG for each year independently.  The only pre-requisite is to sort your dataset by year prior to the proc reg.  This should avoid the need to subsample your data by year.

Ask a Question
Discussion stats
  • 3 replies
  • 3 in conversation