BookmarkSubscribeRSS Feed
amcr729
Fluorite | Level 6

thank you. is the 'data test' code necessary in all cases, or can I just use proc genmod on?  I don't understand what is happening with the 'data test' code. 

SAS_Rob
SAS Employee

No, the first step is not necessary in your case.  It simply generated a sample data set to use.  You should use the GENMOD step on.

amcr729
Fluorite | Level 6

got it, thanks. I ran it, but the results don't seem right to me unless I am reading them wrong. I am assuming that the estimate under "lbetaestimate" is not the beta but the pooled prevalence ratio (contrast estimate). That estimate and CI seem fine but the p-value (<.0001) seems off-- see page 31 of attachment. For all 5 imputations, the p-value is around .2 (see pages 16-30). any thoughts on what could be going wrong here? Many thanks.

 

 

SAS_Rob
SAS Employee

The default test is whether or not it is equal to 0.  You would want to modify that to test if it is equal to 1.  This can be done by specifying the THETA0=1 option on the MIANALYZE statement.

SAS Help Center: PROC MIANALYZE Statement

amcr729
Fluorite | Level 6

Got it, that worked! thanks. I am now trying to get multiply imputed results for a different genmod model (same imputation model, dataset etc) where I am producing contrast estimates for several variables, this time including several categorical ones, and am getting error messages. Thanks in advance for your help. Here is the code and the error message I get when I run proc mianalyze:


proc genmod data=mi_fcs;
class pid ss (ref="0") civil (ref="0") depression (ref="0")
alcohol (ref="0") ed (ref="0") mobility (ref="0") money (ref="0")
unsafe (ref="0") /param=ref;
model share=
ed
civil
alcohol
drugs
depression
ss
mobility
pimp
money
unsafe
viol
estigmasw
estigmahiv
astigmasw/Dist=poisson Link=log;
Repeated subject = pid / type=Ind;
by _imputation_;
estimate 'Incomplete secondary vs. any primary or none' ed 1 0 0 /exp;
estimate 'Complete secondary vs. any primary or none' ed 0 1 0 /exp;
estimate 'Incomplete or complete university or technical vs. any primary or none' ed 0 0 1/exp;
estimate 'Partner, cohab vs single' civil 0 1/exp;
estimate 'Partner, non-cohab vs single' civil 1 0/exp;
estimate 'Alcohol freq =<monthly vs never' alcohol 1 0 0 0/exp;
estimate 'Alcohol freq 2-4x/mo vs never' alcohol 0 1 0 0/exp;
estimate 'Alcohol freq 2-3x/wk vs never' alcohol 0 0 1 0/exp;
estimate 'Alcohol freq =>4x/wk vs never' alcohol 0 0 0 1/exp;
estimate 'Drug use <30 days: yes vs. no' drugs 1/exp;
estimate 'Depression: mild vs none/minimal' depression 1 0 0 0/exp;
estimate 'Depression: moderate vs none/minimal' depression 0 1 0 0/exp;
estimate 'Depression: moderately severe vs none/minimal' depression 0 0 1 0/exp;
estimate 'Depression: severe vs none/minimal' depression 0 0 0 1/exp;
estimate 'Social support: moderate vs low' ss 1 0/exp;
estimate 'Social support: high vs low' ss 0 1/exp;
estimate 'Mobility: nights spent outside Durban <6 mos.' mobility 1 /exp;
estimate 'Share earnings with pimp or other: yes vs. no' pimp 1/exp;
Estimate 'Enough money for needs: A little vs not at all' money 1 0 0 /exp;
Estimate 'Enough money for needs: Moderately vs not at all' money 0 1 0/exp;
Estimate 'Enough money for needs: Mostly or completely vs not at all' money 0 0 1/exp;
Estimate 'safe in daily life: Moderately vs Very much/extremely' unsafe 1 0 0 /exp;
Estimate 'safe in daily life: A little vs Very much/extremely' unsafe 0 1 0/exp;
Estimate 'safe in daily life: Not at all vs Very much/extremely' unsafe 0 0 1/exp;
estimate 'Physical and/or sexual violence ever: yes vs no' viol 1/exp;
estimate 'Enacted SW stigma level' estigmasw 1/exp;
estimate 'Enacted HIV stigma level' estigmaHIV 1/exp;
estimate 'Anticipated SW stigma level' astigmasw 1/exp;
ods output estimates=estimate_ds(where=(index(label,'Exp')=1));
title 'Sharing (Ever)correlates - robust poisson- MI';
run;
proc sort data=estimate_ds ;
by _imputation_;
run;
proc mianalyze data=estimate_ds THETA0=1 ;
by label;
modeleffects LBetaEstimate;
stderr stderr;
run;

 


ERROR: Data set WORK.ESTIMATE_DS is not sorted in ascending sequence. The current BY group has Label
       = Exp(Incomplete secondary vs. any primary or none) and the next BY group has Label =
       Exp(Complete secondary vs. any primary or none).

SAS_Rob
SAS Employee

Try sorting first by LABEL

proc sort data=estimate_ds ;
by label _imputation_;
run;

amcr729
Fluorite | Level 6

that did it. Hopefully that is all from me. Many many thanks for the assistance!

amcr729
Fluorite | Level 6

Hello again, 

When I run PROC MI I get a few warnings, and am wondering what, if anything, I need to do. Here are the code and the warnings:

 

proc mi data=siya3 nimpute=20 out=mi_fcs;
class share agyw drugs depression
ss worksite mobility  pimp homeless moneybin2 unsafe
disclose vs ed civil alcohol violrec viol;
fcs plots=trace(mean std);
var share agyw drugs depression
ss worksite mobility  pimp homeless moneybin2 unsafe
disclose  estigmasw estigmahiv astigmasw
astigmahiv  pills303 pillsreceive303
pillsgive303 vs ed civil alcohol violrec viol ;
fcs discrim(share agyw drugs depression
ss worksite mobility  pimp homeless moneybin2 unsafe
disclose vs ed civil alcohol violrec viol / classeffects=include) nbiter=100;
run;

WARNING: The regression with observed observations results in a perfect fit for variable
         pillsgive303. Imputed values are the predicted values from the model.
WARNING: An effect for variable estigmasw is a linear combination of other effects. The coefficient
         of the effect will be set to zero in the imputation.
WARNING: An effect for variable estigmahiv is a linear combination of other effects. The coefficient
         of the effect will be set to zero in the imputation.
WARNING: An effect for variable astigmasw is a linear combination of other effects. The coefficient
         of the effect will be set to zero in the imputation.
WARNING: An effect for variable astigmahiv is a linear combination of other effects. The coefficient
         of the effect will be set to zero in the imputation.
WARNING: The regression with observed observations results in a perfect fit for variable pills303.
         Imputed values are the predicted values from the model.
WARNING: The regression with observed observations results in a perfect fit for variable
         pillsreceive303. Imputed values are the predicted values from the model.
 
Note that  estigmasw estigmahiv astigmasw astigmahiv, which were included in the analysis model and treated as continuous, are sum scores created by adding other variables together. Pillsgive303, pillsreceive303, and pills303 are also variables included in the analytic model that were created by summing other variables and treated as continuous. Do the warnings mean that I need to include the all the variables used to create those continuous variables in the var statement? If so, should they also be included in the class and fcs discrim statments if they are categorical, even if they themselves were not included in the analytic model? many thanks.
SAS_Rob
SAS Employee

I suspect that the issue is that you are using all the other variables as predictors in the FCS regression models (the default) and there are more predictors than there are observations for the model.  My suggestion would be to reduce the number of predictors by explicitly defining the regression model.

 

fcs regression (pillsgive303=share agyw drugs); as an example.  Obviously you would choose predictors that are most associated with the analyst's model and related to the variable of interest.

amcr729
Fluorite | Level 6

thank you very much for the reply. I have revised the imputation model (See below) but am not sure I am understanding the best way to remove predictors. My understanding is that the imputation model should be congenial (ie consistent with ) the analytic model, i.e. imputation model should include at minimum the same variables that are in the analytic model. When I run the below model, I get the same warnings as before. If you could help me understand better how to further revise the model , I would be very grateful. Thanks.

 

proc mi data=siya3 nimpute=20 out=mi_fcs;
class share agyw drugs depression
ss worksite mobility pimp homeless moneybin2 unsafe disclose vs ed civil alcohol violrec viol;
fcs plots=trace(mean std);
var share agyw drugs depression ss worksite mobility pimp homeless moneybin2 unsafe
disclose estigmasw estigmahiv astigmasw astigmahiv pills303 pillsreceive303
pillsgive303 vs ed civil alcohol violrec viol ;
fcs discrim (vs= agyw drugs depression ss worksite mobility pimp homeless moneybin2 unsafe
disclose estigmasw estigmahiv astigmasw astigmahiv pills303 pillsreceive303 pillsgive303 share ed civil alcohol violrec viol/ classeffects=include );
fcs discrim (share= agyw drugs depression ss worksite mobility pimp homeless moneybin2 unsafe
disclose estigmasw estigmahiv astigmasw astigmahiv pills303 pillsreceive303 pillsgive303 vs ed civil alcohol violrec viol/ classeffects=include);
fcs discrim (viol= share agyw drugs depression ss worksite mobility pimp homeless moneybin2 unsafe
disclose estigmasw estigmahiv astigmasw astigmahiv pills303 pillsreceive303 pillsgive303 vs ed civil alcohol violrec / classeffects=include );
fcs discrim (violrec= share agyw drugs depression ss worksite mobility pimp homeless moneybin2 unsafe disclose estigmasw estigmahiv astigmasw astigmahiv pills303 pillsreceive303 pillsgive303 vs ed civil alcohol viol / classeffects=include );
fcs discrim (agyw= share drugs depression ss worksite mobility pimp homeless moneybin2 unsafe
disclose estigmasw estigmahiv astigmasw astigmahiv pills303 pillsreceive303 pillsgive303 vs ed civil alcohol violrec viol / classeffects=include);
fcs discrim (drugs = share agyw depression ss worksite mobility pimp homeless moneybin2 unsafe
disclose estigmasw estigmahiv astigmasw astigmahiv pills303 pillsreceive303
pillsgive303 vs ed civil alcohol violrec viol / classeffects=include);
fcs discrim (depression = share agyw drugs ss worksite mobility pimp homeless moneybin2 unsafe
disclose estigmasw estigmahiv astigmasw astigmahiv pills303 pillsreceive303
pillsgive303 vs ed civil alcohol violrec viol / classeffects=include);
fcs discrim ( alcohol = share agyw drugs depression ss worksite mobility pimp homeless moneybin2 unsafe disclose estigmasw estigmahiv astigmasw astigmahiv pills303 pillsreceive303
pillsgive303 vs ed civil violrec viol / classeffects=include);
fcs discrim (ss = share agyw drugs depression worksite mobility pimp homeless moneybin2 unsafe
disclose estigmasw estigmahiv astigmasw astigmahiv pills303 pillsreceive303
pillsgive303 vs ed civil alcohol violrec viol / classeffects=include);
fcs discrim (worksite = share agyw drugs depression ss mobility pimp homeless moneybin2 unsafe
disclose estigmasw estigmahiv astigmasw astigmahiv pills303 pillsreceive303
pillsgive303 vs ed civil alcohol violrec viol / classeffects=include );
fcs discrim (mobility =share agyw drugs depression ss worksite pimp homeless moneybin2 unsafe
disclose estigmasw estigmahiv astigmasw astigmahiv pills303 pillsreceive303
pillsgive303 vs ed civil alcohol violrec viol / classeffects=include);
fcs discrim (pimp =share agyw drugs depression ss worksite mobility homeless moneybin2 unsafe
disclose estigmasw estigmahiv astigmasw astigmahiv pills303 pillsreceive303
pillsgive303 vs ed civil alcohol violrec viol/ classeffects=include );
fcs discrim (homeless =share agyw drugs depression ss worksite mobility pimp moneybin2 unsafe
disclose estigmasw estigmahiv astigmasw astigmahiv pills303 pillsreceive303
pillsgive303 vs ed civil alcohol violrec viol / classeffects=include);
fcs discrim (moneybin2=share agyw drugs depression ss worksite mobility pimp homeless unsafe
disclose estigmasw estigmahiv astigmasw astigmahiv pills303 pillsreceive303
pillsgive303 vs ed civil alcohol violrec viol / classeffects=include );
fcs regpmm (pills303 =share agyw drugs depression ss worksite mobility pimp homeless moneybin2 unsafe disclose estigmasw estigmahiv astigmasw astigmahiv pillsreceive303
pillsgive303 vs ed civil alcohol violrec viol );
fcs regpmm (pillsreceive303 =share agyw drugs depression ss worksite mobility pimp homeless moneybin2 unsafe disclose estigmasw estigmahiv astigmasw astigmahiv pills303 pillsgive303 vs ed civil alcohol violrec viol );
fcs regpmm (pillsgive303 =share agyw drugs depressionss worksite mobility pimp homeless moneybin2 unsafe disclose estigmasw estigmahiv astigmasw astigmahiv pills303 pillsreceive303 vs ed civil alcohol violrec viol );
fcs regpmm ( estigmasw = pillsgive303 share agyw drugs depression ss worksite mobility pimp homeless moneybin2 unsafe disclose estigmahiv astigmasw astigmahiv pills303 pillsreceive303 vs ed civil alcohol violrec viol );
fcs regpmm ( estigmahiv = pillsgive303 share agyw drugs depression ss worksite mobility pimp homeless moneybin2 unsafe disclose estigmasw astigmasw astigmahiv pills303 pillsreceive303 vs ed civil alcohol violrec viol );
fcs regpmm ( astigmasw = pillsgive303 share agyw drugs depression ss worksite mobility pimp homeless moneybin2 unsafe disclose estigmasw estigmahiv astigmahiv pills303 pillsreceive303 vs ed civil alcohol violrec viol );
fcs regpmm ( astigmahiv = pillsgive303 share agyw drugs depression ss worksite mobility pimp homeless moneybin2 unsafe disclose estigmasw estigmahiv astigmasw pills303 pillsreceive303 vs ed civil alcohol violrec viol );
fcs discrim (disclose =share agyw drugs depression ss worksite mobility pimp homeless moneybin2 unsafe estigmasw estigmahiv astigmasw astigmahiv pills303 pillsreceive303 pillsgive303 vs ed civil alcohol violrec viol / classeffects=include);
fcs discrim ( unsafe=share agyw drugs depression disclose ss worksite mobility pimp homeless moneybin2 estigmasw estigmahiv astigmasw astigmahiv pills303 pillsreceive303 pillsgive303 vs ed civil alcohol violrec viol / classeffects=include);
fcs discrim ( ed=share agyw unsafe drugs depression disclose ss worksite mobility pimp homeless moneybin2 estigmasw estigmahiv astigmasw astigmahiv pills303 pillsreceive303
pillsgive303 vs civil alcohol violrec viol / classeffects=include);
fcs discrim (civil=share agyw unsafe drugs depression disclose ss worksite mobility pimp homeless moneybin2 estigmasw estigmahiv astigmasw astigmahiv pills303 pillsreceive303 pillsgive303 vs alcohol violrec viol ed / classeffects=include);
run;

 

SAS_Rob
SAS Employee

If you can post your Proc MI output, especially the Missing Data Pattern, then I can be more specific in my response. 

amcr729
Fluorite | Level 6

many thanks. Attached is proc MI output. Note that there are two, related analytic models and the variables in those have been included in the imputation model. I understood that to be best practice. But I wonder if I should have two imputation models, for to be used with each analytic model. 

SAS_Rob
SAS Employee

I suspect the issue is really that you have some singularities in your data that would also appear when you do a complete case analysis or the multiply imputed data.  In other words, the analyst model is likely to run into the same issue because of the data.

 

Even if that is not the case, in truth you have so few missing values relative to the number of observations that not matching the analysts' model is not going to cause much in the way of bias.  It is also probably worth investigating whether or not you gain anything other than further complication with imputing anyway.

 

amcr729
Fluorite | Level 6

thank you! (the problem doesn't arise when I just use complete case analysis, but I take your point about whether or not MI makes sense given amount of missing data).

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

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
  • 28 replies
  • 3227 views
  • 5 likes
  • 4 in conversation