Reference coding in SAS Proc Logistics

noetsi

No cake for spunky
#1
I am doing reference coding and this confuses me. All my variables are dummy variables coded 1 and 0.

This is the code
PROC LOGISTIC DATA=WORK.SORTTempTableSorted
PLOTS(ONLY)=ALL
;
CLASS pd2 (PARAM=REF) pd1 (PARAM=REF) pd3 .....;
MODEL DVD (Event = '1')=pd1 pd2 pd3 pd4 pd5 pd6 pd7 pd8 pd9 pd10 pd11 pd12 pd13 pd15 pd16 pd17 pd18 pd19 pd20 pd21 pd22 pd23 pd24 pd25 pd26 pd27 pd28 pd29 pd30 pd31 pd14 /
SELECTION=NONE
LINK=LOGIT
;
RUN;
QUIT;

For the odds ratio the results are

1631639981616.png


So 1 has a greater impact on the DV taking on a value of 1. I am just not sure what 1 means here. Is is the way I coded it in my raw data or did sas change this by creating new design variables?

It says this, Is this effectively reversing the way I code the variables in the raw data?

1631640139578.png
 

hlsmith

Less is more. Stay pure. Stay poor.
#2
The odds of the outcome equaling 1 for subjects with pd1 = 0 are 0.65 times the odds of subjects with pd1 = 1.

If you don't like this, make CLASS pd2 (PARAM=REF) pd1 (PARAM=REF) pd3 .....,/ ref='0'; Right?
 

noetsi

No cake for spunky
#3
I knew how to interpret it. I did not know how the 0 in the results corresponded to what is 0 in my raw data. That is, is sas leaving my 0 in the data as 0 or changing it to 1 when it builds variables.

If I do this /ref='0' the reference level will be what is 0 in my raw data right? So if 0 is male in the raw data using your example

The odds of the outcome equaling 1 for subjects with pd1 = male are 0.65 times the odds of subjects with pd1 = female.
 

noetsi

No cake for spunky
#4
I get an error message when I do that hlsmith. I am looking for the right way to set the reference to 0. It does not like the ref='0'
 

noetsi

No cake for spunky
#5
This should work, but does not.

Code:
PROC LOGISTIC DATA=WORK.SORTTempTableSorted
        PLOTS(ONLY)=ALL
    ;
    CLASS pd2     (REF='0') pd1     (REF='0') / param=ref;
    MODEL DVD (Event = '1')=pd1 pd2      
        SELECTION=NONE
        LINK=LOGIT
    ;
RUN;
QUIT;
 

hlsmith

Less is more. Stay pure. Stay poor.
#6
If I can't figure out the coding scheme or estimates in a model - I simply it down to one IV and run it via the logistic and as a frequency table and compare the output as a quality check. Have you done anything like this?
 

noetsi

No cake for spunky
#7
If I can't figure out the coding scheme or estimates in a model - I simply it down to one IV and run it via the logistic and as a frequency table and compare the output as a quality check. Have you done anything like this?
I am not sure what that means. I figured out the error, although it baffles me.

Code:
PROC LOGISTIC DATA=WORK.SORTTempTableSorted
        PLOTS(ONLY)=ALL
    ;
    CLASS pd2     (REF='0') pd1     (REF='0')/ param=ref;
    MODEL DVD (Event = '1')=pd1 pd2        
        /*SELECTION=NONE
        LINK=LOGIT */
    ;
RUN;
QUIT;
Runs fine. I don't understand why that default coding I commented out matters. But it messes up the code.
 

hlsmith

Less is more. Stay pure. Stay poor.
#9
What I meant was I will run a simple logistic model and proc freq / odds ratio and confirm they are kicking out similar results if I have a reference group concern.
 

noetsi

No cake for spunky
#10
If you want the reference to be 0 for everything in the class statement is this the way to do it with genmod?

Code:
PROC GENMOD DATA=WORK.SORTTempTableSorted
        PLOTS(ONLY)=None
;
    CLASS 
"Age 25 to 44"n (ref ="0")
"Associate’s degree"n (ref ="0")
"Bachelor’s degree"n (ref ="0")
"Beyond a bachelor’s degree"n (ref ="0")
"High school diploma or equivalen"n (ref ="0")
"Individuals has a significant di"n (ref ="0")
"Postsecondary education no degre"n (ref ="0")
"Race: Black"n (ref ="0");
 

fed2

Active Member
#12
hmm interesting. havent seen "name literals" in a while. Must be you have variables with 'illegal' sas names? ie you set the option SAS VALIDVARNAME=any?

Ive only seen it when using databases that allow non-sas admissable stuff, so you have to refer to them in this fashion.

I feel like this may do what you want if you have numeric values that say "0" as the referent level.
 

noetsi

No cake for spunky
#13
I have never done it that way, with the "" and n characters. Just look at your output to see if it worked. :)
Sorry the ''"" n has nothing to do with reference codes or regression. It is how SAS deals with variables that violate it naming conventions such as having spaces between words. I build my models with PROC SQL from state data bases so these conventions are necessary (it is more complicated than that, but asides the point of this).

What I was asking about was the need to use (ref ="0") for each variable. I thought maybe you could just do it once and it cover all class variables.

I never trust my output :)
 

noetsi

No cake for spunky
#14
hmm interesting. havent seen "name literals" in a while. Must be you have variables with 'illegal' sas names? ie you set the option SAS VALIDVARNAME=any?

Ive only seen it when using databases that allow non-sas admissable stuff, so you have to refer to them in this fashion.

I feel like this may do what you want if you have numeric values that say "0" as the referent level.
I essentially do this another way. :p
 

fed2

Active Member
#15
according to SAS docs, you can give a 'global' reference after '/', i assume it applies to all vars. ive never used this.

class xxx yyy / ref = "0";