Programming the statistical procedures from SAS

How to choose a dummy manually for regressing as an intercept?

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 144
Accepted Solution

How to choose a dummy manually for regressing as an intercept?

Hello everybody,
I want to run a regression with dummies. My dummies are half-hour period variables which are from 9 to 12 o'clock and I have totally six dummies. However, SAS just predict five dummies and one intercept in a regression model as you know and the last dummy is the intercept subtracted by the aggregate of other dummies (in my research the dummy variable which is made for half-hour period from 11:30 to 12 o'clock). SAS choose which dummies to be the intercept and I want to choose it by myself.
I use codes which are shown below:

 

proc glm data=Sampledata_02_mer;
   class TRD_EVENT_ROUFOR;
   model adjusted_volume = TRD_EVENT_ROUFOR / solution;
   ods select ParameterEstimates;
quit;

 

How can I do that?
Thanks in advance.


Accepted Solutions
Solution
‎07-30-2017 03:51 PM
Super User
Posts: 19,875

Re: How to choose a dummy manually for regressing as an intercept?

Posted in reply to aminkarimid
proc glm data=sashelp.class;
class sex (ref='F');
model weight  = height age sex;
run;

View solution in original post


All Replies
Trusted Advisor
Posts: 1,933

Re: How to choose a dummy manually for regressing as an intercept?

[ Edited ]
Posted in reply to aminkarimid

In the CLASS statement, use the REF= option.

http://documentation.sas.com/?docsetId=statug&docsetVersion=14.2&docsetTarget=statug_glm_syntax04.ht...

 

Although, for most purposes, there is no reason to do this at all. This doesn't change the model fit, it doesn't change the predicted values, it doesn't change the interpretation of anything. The only reason I can think of to actually use the REF= option is if you are running a scientific experiment where one level of the CLASS variable is a control group, a situation you don't have.

Frequent Contributor
Posts: 144

Re: How to choose a dummy manually for regressing as an intercept?

Posted in reply to PaigeMiller
The "REF=option" just can be first and last. However, I have six dummies that I want to choose between them and the result absolutely different by changing the reference category.
Trusted Advisor
Posts: 1,933

Re: How to choose a dummy manually for regressing as an intercept?

[ Edited ]
Posted in reply to aminkarimid

aminkarimid wrote:
The "REF=option" just can be first and last. However, I have six dummies that I want to choose between them and the result absolutely different by changing the reference category.

One of the reasons I provide the link to the proper documentation so that you (and everyone) can see there is a third option which is not first and is not last. This third option is the one you want, as shown by @Reeza.

 

As I tried to point out above, the use of these coefficients is problematic, as you have already shown that depending on what you change in the REF option, the coefficients change. THEY ARE NOT UNIQUE. THERE IS NO CORRECT UNIQUE ANSWER. THERE IS NO CORRECT UNIQUE MODEL parameterization. And yet they are all the same model.

 

You have to be careful in your interpretation of these coefficients. To insist that you want a specific REF= option is fine if you know how to interpret them, so let me explain. The delta between any two coefficients is constant, regardless of the REF= option, but the individual coefficients are not to be interpreted in any other way. You can interpret the delta between two coefficients, but not the coefficients themselves.

 

Better yet, you should compute LSMEANS for each level of your category variable. THESE ARE UNIQUE. These tell you what you really want to know. Make your life simple, interpret the LSMEANS and not the model coefficients.

Frequent Contributor
Posts: 144

Re: How to choose a dummy manually for regressing as an intercept?

Posted in reply to PaigeMiller

Hello @PaigeMiller

Here is my first result:

First resultFirst result

When I use "REF=first", the result is:

table02.PNG

Question01: Why the result have changed when I use "ref" that it is contrary to what you mentioned?
Question02: The "REF" option can be "first" or "last" and I want to choose reference category between them. How can I do that?

 

Thanks.

Solution
‎07-30-2017 03:51 PM
Super User
Posts: 19,875

Re: How to choose a dummy manually for regressing as an intercept?

Posted in reply to aminkarimid
proc glm data=sashelp.class;
class sex (ref='F');
model weight  = height age sex;
run;
PROC Star
Posts: 768

Re: How to choose a dummy manually for regressing as an intercept?

Posted in reply to aminkarimid

Use the ORDER= option in the PROC GLM statement to control the order that the procedure interprets the class variables as in this small example

 

proc sort data = sashelp.iris out=iris;
   by descending species;
run;

proc glm data = iris order=data;
   class species;
   model SepalLength = species / solution;
   ods select ParameterEstimates;
run;quit;

 

You can see other ways of controlling it in the ORDER= part of the PROC GLM documentation here

 

https://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/viewer.htm#statug_glm_sect008...

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 356 views
  • 7 likes
  • 4 in conversation