Hi,
I am trying to obtain adjusted means from genmod for an independent variable (crit1, 2 levels) at different levels of a covariate (disease, 4 levels: IBD, Pso, Art, MDD). Following is the log of the procedure.
14393 proc genmod data=bullying.anaset ;
14394 a = _mean_;
14395 b = _resp_;
14396 d = b/a + log(a);
14397 variance var = a**2;
14398 deviance dev =d;
14399 class crit1 sex family ter_edu safe disease;
14400 model impairment =crit1 disease age nights mobtime sex family ter_edu safe /link=log
14400! type3;
14401 lsmeans crit1/ at disease='Art';
--
22
202
14402 lsmeans crit1/ at disease='Pso';
--
22
202
14403 lsmeans crit1/ at disease='MDD';
--
22
202
14404 lsmeans crit1/ at disease='IBD';
--
22
202
ERROR 22-322: Syntax error, expecting one of the following: ;, ALPHA, CL, CORR, COV, DIFF, E,
EPSILON, SINGULAR.
ERROR 202-322: The option or parameter is not recognized and will be ignored.
14405 where contract ne 3 and job=1;
14406 run;
Despite I used the sintax as suggested in the support documentation, SAS 9.2 does not recognize the AT option. Could anyone show me how to do it right?
Thank you very much,
L.
I think the AT option applies to continuous covariates not discrete. Look more closely at the model and class statement in the example.
Maybe you want the CRIT1*DISEASE interaction LSMEANS but that effect is not in your model.
Yes, crit1*disease would give adjusted means for crit1 at different levels of disease; however, I won't include it in the model since the interaction is not significant. Anyway I have solved the problem.
1. the AT option does not work in genmod
2. Plus, it does need continuous variables
3. Adjusted means at different levels of a categorical variable can be estimated with the ESTIMATE statement in genmod.
First I have inspected the vector of coefficients to see how the variables are parametrized in the model (you can do this by calling lsmeans crit1/e; ). Age, night and mobtime are continuous variables: the coefficient in the ESTIMATE statement is the sample mean. Sex, family, ter_edu, safe are dichotomic variables.Then I coded a series of ESTIMATE statements as follows:
proc genmod data=bullying.anaset ;
a = _mean_;
b = _resp_;
d = b/a + log(a);
variance var = a**2;
deviance dev =d;
class crit1 sex family ter_edu safe disease;
model impairment =crit1 disease age nights mobtime sex family ter_edu safe /link=log type3;
estimate 'Crit1=0 - Arthritis' intercept 1
crit1 1 0
disease 1 0 0 0
age 45.894
nights 1.3955
mobtime 0.682
sex 0.5 0.5
family 0.5 0.5
ter_edu 0.5 0.5
safe 0.5 0.5;
estimate 'Crit1=1 - Arthritis' intercept 1
crit1 0 1
disease 1 0 0 0
age 45.894
nights 1.3955
mobtime 0.682
sex 0.5 0.5
family 0.5 0.5
ter_edu 0.5 0.5
safe 0.5 0.5;
estimate 'Crit1=0 - IBD' intercept 1
crit1 1 0
disease 0 1 0 0
age 45.894
nights 1.3955
mobtime 0.682
sex 0.5 0.5
family 0.5 0.5
ter_edu 0.5 0.5
safe 0.5 0.5;
estimate 'Crit1=1 - IBD' intercept 1
crit1 0 1
disease 0 1 0 0
age 45.894
nights 1.3955
mobtime 0.682
sex 0.5 0.5
family 0.5 0.5
ter_edu 0.5 0.5
safe 0.5 0.5;
estimate 'Crit1=0 - MDD' intercept 1
crit1 1 0
disease 0 0 1 0
age 45.894
nights 1.3955
mobtime 0.682
sex 0.5 0.5
family 0.5 0.5
ter_edu 0.5 0.5
safe 0.5 0.5;
estimate 'Crit1=1 - MDD' intercept 1
crit1 0 1
disease 0 0 1 0
age 45.894
nights 1.3955
mobtime 0.682
sex 0.5 0.5
family 0.5 0.5
ter_edu 0.5 0.5
safe 0.5 0.5;
estimate 'Crit1=0 - Psoriasis' intercept 1
crit1 1 0
disease 0 0 0 1
age 45.894
nights 1.3955
mobtime 0.682
sex 0.5 0.5
family 0.5 0.5
ter_edu 0.5 0.5
safe 0.5 0.5;
estimate 'Crit1=1 - Psoriasis' intercept 1
crit1 0 1
disease 0 0 0 1
age 45.894
nights 1.3955
mobtime 0.682
sex 0.5 0.5
family 0.5 0.5
ter_edu 0.5 0.5
safe 0.5 0.5;
where contract ne 3 and job=1;
run;
The AT option most certainly DOES work on the LSMEANS statement from at least version 9.22 onward. @data_null's statement about the argument to the AT option being continuous is the key element here (acknowledged in your point 2).
Now, why not use the LSMEANS statement, with an ILINK option to put things back on the original scale, to get the values you want? It plugs in the mean values of all continuous variables, and uses the same coefficients that you have hardcoded into your ESTIMATE statements (see the E option for the LSMEANS statement for more info on this).
Steve Denham
Thanks Steve. Most likely I have a previous version of SAS then, because AT is not recognized even when I use continuous variables.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.