BookmarkSubscribeRSS Feed
Fluorite | Level 6

Hi All, 


I'm using GEE via Proc Genmod, continuous outcome, Gamma Distribution and log for the link function. The code I used is:  

MODEL los=cdiff / DIST=GAMMA link=LOG ;
lsmeans /exp cl diff=control means ilink;


The LSmeans output is as follows



Screen Shot 2018-10-15 at 10.28.03 PM.png


I can see the mean values for Cdiff yes and no (19.29 and 8.38), how do I obtained the confidence interval for the difference in means between those with CDIFF=Y and CDIFF=N, the ilink does not provide the difference in means so was wondering if there is a way a round it.


Thanks in advanced!


The difference in means of a binary predictor is also called its marginal effect. As such, it can be estimated using the Margins macro which will can provide a confidence interval for the difference. It can also be estimated using the NLMeans macro. It can also be estimated directly as a nonlinear function of model parameters which is something that can be done with the NLEstimate macro. See the examples in the Results tab of the documentation for these macros at the provided links.

Fluorite | Level 6 _s_
Fluorite | Level 6


I am trying to run the margins macro under SAS/EG within the CCW VRDC portal. While it generates standard GENMOD estimates, it doesn't appear to recognize the Margin= or Effect= parameters. I've suppressed the search for a newer version of the macro in a copy. That eliminated one error. The dist=gamma and link=log specifications do work.


(BTW, the VRDC requires approval for any download and doesn't allow copying of programs or logs directly. If you need to see them, I'll have to request approval to download.)


The log of the program is displaying another error message: Libref SUBFUNC is not assigned. I don't find a Libref in the macro. Is this part of the macro or something strange happening in the VRDC SAS/EG environment?


Also, is the reference value of a binary independent variable set the same in the macro as in GENMOD? Does the macro parameter apply only to CLASS variables?


Finally, how does the margins macro differ from the QLIM plots of marginals? A basic TOBIT model may give us an alternative for comparison.

Thanks in advance,



Some questions:

1. what version of SAS (not Enterprise Guide) are you running? submit this to find out (results show in the log):

%put Release: &sysvlong    System: &sysscp &sysscpl;

2. what makes you say that margins= (note it is not margin=) and effect= are not recognized? are there specific errors? If you see something like following, then you didn't type the margins or effect correctly:

ERROR: The keyword parameter BLAH was not defined with the macro.

3. please show the call of the macro that is causing problems.


Note that, as stated in the macro documentation, if you see this message it is because your system is not able to connect across the internet to check for new versions. but this does not affect the macro in any way.

NOTE: Unable to check for newer version of Margins macro.


Yes, the reference levels for CLASS predictors are the same as GENMOD. 

No, the macro can handle continuous or CLASS predictors.

You can use QLIM, but its MARGINAL option only provides marginal effects at the observation level (not the average marginal effect or the marginal effect at the mean) and are only correct for variables not involved in interactions. Also, it does not provide standard errors or confidence intervals for the individual marginal effects. 



Fluorite | Level 6 _s_
Fluorite | Level 6


Release: 9.04.01M5PO91317 System: LIN X64 Linux


The macro does not, for example, create _Margins or _MEffect.


I'll have to download the program and copy the macro call.






Fluorite | Level 6 _s_
Fluorite | Level 6


Dave: Continuing with response to 3 (margins macro call).


ODS trace on;
ODS output _Margins PERSIST=RUN ;
model=TCcd TOTMCRCLMTS1, dist=GAMMA, link=LOG,roptions=event='2',
margins=TCcd TOTMCRCLMTS1, options=diff cl)
model=TCcd TOTMCRCLMTS1 MDCRcovTS1 MDCRcovTS2 HMOcovTS1 HMOcovTS2, dist=GAMMA, link=LOG,
margins=TCcd TOTMCRCLMTS1 HMOcovTS1 HMOcovTS2, options=diff cl)
ODS _all_ close;






Margins is a macro, not a procedure, so it does not make use of ODS. As stated in the macro documentation, the _Margins data set is created automatically when margins= is specified. The _MEffect data is created automatically when effect= is specified. _MEffect will not be created by your macro calls. If you want to combine the data sets from multiple macro calls, use PROC APPEND after each call.


Note that roptions= is ignored since the EVENT= option in GENMOD is only used for binomial models (or multinomial, but the macro does not support those). EVENT= has no logical meaning with a continuous response distribution.


The macro provides margin estimates for one variable or variable combination. If two or more variables are specified, it provides estimates for all of the unique combinations of the levels of those variables. It does not estimate the margins for the levels of the first variable and then estimate margins for the levels of the second variable, and so on. If that is desired, use the macro multiple times specifying each variable in turn. If a continuous variable is specified (either alone or in combination with others), and if that continuous variable has a large number of levels, the number of estimates will be very large. If all pairwise differences are also requested, the number of them will be enormous. The data set that must be created to compute those estimates will be extremely large. Margin estimates for a continuous variable are typically computed for specified values of the variable. This can be done either using margwhere= if the values are in the data, or with margindata= if not. Or, if margin estimates for one variable are desired at specific levels of one or more other variables, then use either at= and atwhere= if the values are in the data or at= and atdata= if not. 


Similarly, only one variable may be specified in effect= if marginal effects are desired.


Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 6 replies
  • 3 in conversation