BookmarkSubscribeRSS Feed
KarenA_
Calcite | Level 5

Hello,

I wonder if it is possible to obtain an overall result for a comparison of means for a categorical variable.

The standard SAS codes show how to obtain combined parameter estimates (for each of the levels of my variable),

but I haven't found instructions on how to obtain combined overall p-values for categorical variables anywhere.

The "outstats=xxx" option in proc glm (by _imputation_) allows me to obtain overall p-values for each imputation.

But I cannot combine them simply by stating proc mianalyze data=XXX as SAS will not recognize the variables

listed under _SOURCE_ as modeleffects.

Thank you very much in advance for any ideas on this!

19 REPLIES 19
SteveDenham
Jade | Level 19

Hi Karen,

Check out Example 58.6 Reading GLM Results from PARMS= and XPX!= Data Sets in the documentation, and Example 58.8 Reading Mixed Model Results with Classification Variables.  You will probably have to add a TEST statement to get what you are finally looking for.

If these examples don't get you started in the right direction, please provide additional details.

Steve Denham

KarenA_
Calcite | Level 5

Thank you very much for your answer! I could not really work out how to get results for the overall F-test from these examples. However, when looking for how to combine imputed results on LS-Means, I found this document (that also covers a solution for the F-test problem) A Method of Using Multiple Imputation in Clinical Data Analysis | www.pnwsug.org

I have not tried it yet but I hope it will work!

SteveDenham
Jade | Level 19

Interesting paper and approach to getting LSmeans and the associated standard errors.  I have, however, "great fear and loathing" about the calculation of standard errors for the differences between LSmeans across imputation, as I don't see a variance-covariance matrix in the code in Example 7.  I fear that without the covariances, somehow averaged over imputations, the standard errors of the differences will be off.  See https://communities.sas.com/message/149498#149498 for more on this, where it becomes apparent that the assumption of independence between variables and levels of variables leads to mis-estimation of standard errors of the differences between LSmeans (and that would be the loathing part, because it was my mistake).  If this is where you eventually need to be (comparing levels of fixed effects after imputation), then it is going to get much more difficult.

Steve Denham

KarenA_
Calcite | Level 5

Thank you for the critical comments! It's a pity that multiple imputation still is quite complicated for certain types of analysis - I hope it will get more easily applicable in the future!

aggie01whoop
Calcite | Level 5

Hi Karen,

Can you provide specific code for what you have done to circumvent this problem?

I suspect I am encouring a similar issue.  I want to obtain an overall Fand p value for treatment (from the mianalyze step) for a model that has a 3-level categorical predictor (3 different types of treatment).

I get a warning message when I run the glm step.

proc glm data = XX;

class tx_condition;

model continuous_dv = continuous_iv tx_condition/inverse;

by _imputation_;

ods output

parameterestimates = glmparms

invxpx = glmpxi;

run;

***WARNING MESSAGE:

'ParameterEstimates' was not created. ****

Then when I turn to step 3 (mianalyze) I get an error.

proc mianalyze;

class tx_condition;

model effects intercept continuous_iv tx_condition;

parms = glmparms;

xpxi = glmpxi edf = 218;

run;

*** ERROR MESSAGE:

Parms Statement is not valid or it is used out of proper order***


I have read around and suspect it's an issue with the class statement but I'm not sure how to get around this problem.

Thanks in advance for any thoughts/suggestions!

Amy

SteveDenham
Jade | Level 19

Amy,

On the proc mianalyze front, the parms=, xpxi=, and edf= statements should be made options in the proc mianalyze statement.  That is:

proc mianalyze parms(classvar=full)=glmparms xpxi=glmpxi edf=218;

/* Note the inclusion of the classvar= option to indicate that there are categorical variables */

class tx_condition;

model effects intercept continuous_iv tx_condition;

run;

For the proc glm, add solution as an option after inverse.

Good luck.

Steve Denham

KarenA_
Calcite | Level 5

Hi Amy,

I am not sure if I'll be of great help as I am absolutely new to multiple imputation myself.

I did notice that SAS won't create the "parameterestimates=" output if you don't specify /solution clparms

(or only one of the two, I am not sure).

As in model y = x / solution inverse clparm

I'm still working on my code and figuring out what exactly to put. Good luck with your work!

Karen

KarenA_
Calcite | Level 5

However, when I use exactly this code, I get:

"ERROR: The XPXI= data set can not be used with CLASS variables or effects."   ...

SteveDenham
Jade | Level 19

More digging.  So in the Details part of the documentation, under Input Data Sets, in the very last sentence: "Note that this combination can be used only when each effect is a continuous variable by itself." (referring to PARMS= and XPXI=).

Where I would go now.  Use PROC MIXED rather than PROC GLM.  This should not add any additional concerns, and will provide additional flexibility if random or repeated factors are included in the model.  The options that apply then will be PARMS(CLASSVAR=FULL)= and COVB(EFFECTVAR=ROWCOL)=

So, something like:

proc mixed data = XX;

class tx_condition;

model continuous_dv = continuous_iv tx_condition/covb solution;

by _imputation_;

ods output

solutionf = glmparms

covb = glmcovb;

run;

proc mianalyze parms(classvar=full)=glmparms covb(effectvar=rowcol)=glmcovb edf=218;

/* Note the inclusion of the classvar= option to indicate that there are categorical variables */

/* Also the use of the covb option to get the covariance matrix into mianalyze                    */

class tx_condition;

model effects intercept continuous_iv tx_condition;

run;

Maybe this one will work better.

Steve Denham

aggie01whoop
Calcite | Level 5

Thank you both VERY MUCHfor your help.  Proc mixed seems to work except that I cannot get a main effect for tx_condition from the mianalyze statement -- I only get specific comparisons to the control/reference group. Is there a way to specify things to get that overall F (and p value)  for my categorical predictor tx_condition (with 3 levels). I think this is similar to the question Karen had previously.

Amy

SteveDenham
Jade | Level 19

  I know it involves the MULT option in the PROC MIANALYZE statement, but if there are multiple class variables, I am stuck. That is where the TEST statement comes in.  Unfortunately, the syntax is about as clear as mud for doing the overall F test.

Steve Denham

BarbClothier
Calcite | Level 5

I've had the best luck by creating dummy variables for my categorical variables and using those instead, or keeping that in mind with looking at the parameter estimates and covariance matrix data sets that have been outputted.  If you don't use dummy variables from the beginning, then you may need to rename the Effect variable using a combination of the categorical variable name and its various levels of values names.  Order of the variable levels are important also.  Make sure the rows correspond to the columns of your new covb that you may have to create.  I have had to even rename the Col1 and etc... to instead "Black" and etc..., as an example, and then I was able to get the Test statement to work.  For example, Test Black=Asian=AmIndian=0/Mult where White was the reference group.   I tried the classvar=Full and was able to confirm my results using dummy variables, but then the Test statement wouldn't work  for me with that approach.

TZaihra
Fluorite | Level 6

Dear All,

I was looking at your thread, in order to fix a similar issue I have while fitting GEE (proc genmod) via multiple imputation..mostly towards the end here I want to combine my results..I tried the solutions mentioned in the thread above but I keep getting error that "Variable GENDER is not in the PARMS= data set." although it is very well there.

Below is my code:

proc mianalyze parms(classvar=full)=gmparms covb(effectvar=rowcol)=gmcovb edf=218;

class GENDER grage gr_revenu2 SM02 CARDIAC_RELATED_COND PHYSICIAN NAM PATIENT NEUROTIC_DISORDER;

modeleffects GENDER grage gr_revenu2 SM02 CARDIAC_RELATED_COND NEUROTIC_DISORDER

centred_AC centred_AQ centred_BM centred_SE ;

run;

I would appreciate any help.

Thanks

Tasneem

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is Bayesian Analysis?

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 19 replies
  • 8875 views
  • 1 like
  • 7 in conversation