Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- Analytics
- /
- Stat Procs
- /
- Proc reg with year dummies

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

07-22-2017 11:17 PM - edited 07-23-2017 12:47 AM

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to kelSAS

07-22-2017 11:52 PM

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.

Thanks,

Jag

Jag

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Jagadishkatam

07-23-2017 01:12 AM

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Reeza

07-24-2017 08:02 PM

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to kelSAS

07-24-2017 08:41 PM

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.