BookmarkSubscribeRSS Feed
kelSAS
Obsidian | Level 7

I am trying to run a regression that has year dummy variables in the equation, and have two questions regarding it.

 

First question is to do with how to include more than 30 year dummies in PROC REG.

 

Currently, I have created year dummies using the following code.

data X;

set X;

array yrdummy(*) dy&startyr - dy&endyr;

do i=1 to dim(yrdummy);

if fyear = i+&startyr then yrdummy{i} = 1;

else yrdummy{i} = 0;

end;

run;

 

Now, I am only test-running regression with 5 years (&startyr=2011 and &endyr=2015),

but I will eventually run with more than 30 years of data. 

How do I efficiently add these created dummy variables in my regression? 

 

Second question is to do with regression outcome.

 

When I run regression, I usually write the following code. 

 

proc reg data=x outest=x1 noprint;

model y=x1 x2; *here I need to include yr dummies after x2;

run;

 

Now, the outcome I need is the coefficients on x1 and x2, not the coefficients on yr dummies, and adj R-squared and number of observations. But when I use 'outest', I can't find R-square or number of observations. Do I have to use other means for my output or is there a way to have coefficients, R2, n and other STATA-like information (SSR, SSE, SST etc)?

 

 

 

 

4 REPLIES 4
Jagadishkatam
Amethyst | Level 16

I believe your array is fine, it should work even if you are having more than 30 years as you are using the macro variable for the start and end year.

 

About the coefficients, and adj R-squared and number of observations. Please try to use th odes trace on and off as i used and in the log you get something as displayed.

 

then in order to get the data into datasets try

 

ods output parameterestimates=parameterestimates nobs=nobs ;

proc reg data=sashelp.class outest=x;
model age=height weight;
run;

ods output close;

 

the ods output statement will help you get the expected dataset.

 

image.png

Thanks,
Jag
Reeza
Super User

If you can use PROC GLM instead you can add the year variable as a CLASS variable and not have to create dummy variables. 

kelSAS
Obsidian | Level 7

Can you please write SAS commands to run proc glm without year dummy?

I have y(dependent var) and x1, x2, ..., x3 and year that has year figures. Thank you in advance.

 

Reeza
Super User

@kelSAS wrote:

Can you please write SAS commands to run proc glm without year dummy?

I have y(dependent var) and x1, x2, ..., x3 and year that has year figures. Thank you in advance.

 



http://www.lexjansen.com/mwsug/1999/paper15.pdf

http://www2.sas.com/proceedings/sugi22/STATS/PAPER267.PDF

 

 

There are a lot of examples online. Note that there still are year dummy variables, you just don't have to code/create them. You may also want to review the parameterization methods for creating dummy variables and how to specify that in SAS. The default is GLM coding while you probably want referential coding, even if you're not using that estimate. 

 

 

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 ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 2709 views
  • 0 likes
  • 3 in conversation