BookmarkSubscribeRSS Feed
ncross
Calcite | Level 5

Hi

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

3 REPLIES 3
PGStats
Opal | Level 21

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

PG
ncross
Calcite | Level 5

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

mkeintz
PROC Star

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;

run;

proc reg data=need;

  by year;

  model y=x1 x2;

quit;

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.

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 3 replies
  • 875 views
  • 0 likes
  • 3 in conversation