Programming the statistical procedures from SAS

Translate proc genmod to proc glimmix

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 7
Accepted Solution

Translate proc genmod to proc glimmix

Hello - I am trying to translate a bi-variate function from genmod to glimmix as I need to add weights to the analysis which I am not able to do in genmod.

The genmod code below, gives me the exponentiated betas for my analysis (prevalence rates) and I am trying to do the same for glimmix, though the code is slightly off. Was doing my best though can't seem to get the last part. I've been teaching myself so code may look a bit awkward, appreciate any assistance. Thank you!

proc genmod data = mydata desc;

class gender (ref='0') / param = ref;

model heat=gender /link=log dist=bin type3;

by HOSP_REGION;

ods output parameterestimates = mydata1;

run;

data mydata1;

setmydata1;

      OR = exp(estimate);

      LL = exp(lowerwaldcl);

      UL = exp(upperwaldcl);

proc print data = mydata1;

      var parameter OR LL UL;

run;

proc glimmix data=fullexp.mydata;

class gender;   ( Was trying to add the ref = 0 here and the /param=ref though couldn't figure that out)

model heat(desc)=gender /link=log dist=bin solution CL;

weight discwt;

ods output parameterestimates = mydata2;

run;

data mydata2;

      set mydata2;

      OR = exp(estimate);

      LL = exp(lower);

      UL = exp(upper);

proc print data = mydata2;

      var parameter OR LL UL;  (I don't think it's called parameter here....)

run;


Accepted Solutions
Solution
‎06-09-2013 12:57 PM
Super User
Super User
Posts: 6,144

Re: Translate proc genmod to proc glimmix

You are missing the period in format name in the FORMAT statement so SAS thinks you are listing another variable.

format gender genderA. ;

View solution in original post


All Replies
Regular Contributor
Posts: 152

Re: Translate proc genmod to proc glimmix

The syntax for the CLASS statement in PROC GLIMMIX differs from that in PROC GENMOD (see the documentation).  The sort order for variables specified in the PROC GLIMMIX CLASS statement is that of the ORDER= option of the PROC GLIMMIX statement (default:  ORDER=FORMATTED).  Therefore, precede the PROC GLIMMIX "paragraph" with a PROC FORMAT "paragraph" specifying format values for your CLASS statement variables that order them in the direction you want.  In your example, you can do something like the following:

    proc format;

        value genderf 0="} Reference";

    run;

    proc glimmix. . . .;

        class gender;

        . . . .

        format gender genderf.;

    run;

The right brace, "}", in the PROC FORMAT value statement label orders the value of zero to the end, making it the reference category.

PROC SURVEYLOGISTIC may be preferable to PROC GLIMMIX for weighted analyses, though PROC SURVEYLOGISTIC does NOT have the MODEL statement option, LINK=LOG, to obtain "prevalence rates" and though you seem to be specifying odds ratios ["OR"] rather than prevalence ratios as your output parameters.   

Occasional Contributor
Posts: 7

Re: Translate proc genmod to proc glimmix

Thank you for the input. Greatly appreciated.

I do have other variables that I will be running in which the reference is not 0, will the PROC FORMAT statement work if the reference is 2 or 3? Also will this work when I am running the model with multiple class statements all with different references? I will try either way to see.

The OR was a typo from a previous model. I am calculating prevalence rates so PROC GLIMMIX is preferred.

Thanks.

Regular Contributor
Posts: 152

Re: Translate proc genmod to proc glimmix

The PROC FORMAT technique will work with any reference level you provide it (0,2,3, etc.) as long as the formatted value of the range of values of the corresponding VALUE.statement name is preceded by the right brace(s) and the FORMAT statement in the PROC GLIMMIX procedure associated the variable name with the appropriate VALUE statement name.

You can change the reference level even for the same variable if you provide a corresponding, unique PROC FORMAT VALUE statement for that variable and associate the variable name with the appropriate VALUE statement name.  For example, if SEX were a variable in your model, and if you wanted men [SEX=2] to be the reference category in one analysis and women [SEX=1] to be the reference category in another analysis, you could create two different format values for the different reference levels of the variable, SEX:

   proc format;

       value sexa 1="Women" 2="} Men";

       value sexb 1="} Women" 2="Men";

   run;

   proc glimmix . . . .;

       class sex . . . .;

       . . . . .;

       model y= sex. . . .;

       title "Model with men as the reference group for the variable, sex";

       format sex sexa. . . . .;

   run;

   proc glimmix . . . .;

       class sex .  . . .;

      . . . .;

      model y=sex . . . .;

      title "Model with women as the reference group for the variable, sex";

      format sex sexb. . . . .;

  run;

For variables with multiple levels, you can use one or more right braces in the formatted values for levels to order the levels for the output; the level with the most right braces is considered the reference level.

Occasional Contributor
Posts: 7

Re: Translate proc genmod to proc glimmix

Thank you. I am trying what you are suggesting in the coding above, using my own variables, though I get an error and warning. Apologies in advance I don't work with proc format so I may be interpreting it incorrectly, though other examples I have seen online show a similar coding with no errors.

proc format;

value genderA 0="Women" 1="} Men";

run;

proc glimmix data=mydata;

class gender;

model heat(desc)=gender /dist=bin solution CL;

weight discwt;

title "Model with men as the reference group for the variable, gender";

format gender genderA;

run;

WARNING: The variable genderA is not defined in the program.

ERROR: Undefined variables are not permitted in GLIMMIX statements.

NOTE: The SAS System stopped processing this step because of errors.

Solution
‎06-09-2013 12:57 PM
Super User
Super User
Posts: 6,144

Re: Translate proc genmod to proc glimmix

You are missing the period in format name in the FORMAT statement so SAS thinks you are listing another variable.

format gender genderA. ;

Occasional Contributor
Posts: 7

Re: Translate proc genmod to proc glimmix

I knew it had to be something simple, sorry I missed it in the first place.

Thank you both very much.

☑ This topic is SOLVED.

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

Discussion stats
  • 6 replies
  • 419 views
  • 6 likes
  • 3 in conversation