BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
stodo53
Fluorite | Level 6

Hi all,

I am having issues with imputing a few variables in my dataset. I am working with complex survey data with weights and I also am working with a subpopulation of my dataset. Specifically when I run the following code:

*Proc MI imputation;
proc mi data=combined seed=1180431796 nimpute=10 out=combined_imp_fcs;
class t1_30grp t1_province t1_10_5cat t1_conchealth t1_poverty_2cat I2 t1_interruption;
fcs nbiter=10 logistic(t1_conchealth/details) logistic(t1_30grp t1_poverty_2cat) regression(oasis) regression(cesd10_resc);
var t1_province t1_10_5cat I2 t1_interruption mos_ss t1_cesd t1_oasis t1_conchealth t1_30grp oasis
cesd10_resc t1_poverty_2cat covid_weights;
run;

This is the warning message:

Warning msg.png

 

When I go to the next step and run my model with proc surveyreg, there are no issues. However, I encounter another problem when running proc mianalyze. 

proc mianalyze parms=combinedimp_regparms;
by include;
class t1_30grp t1_province t1_10_5cat t1_conchealth t1_poverty_2cat I2 t1_interruption;
modeleffects intercept t1_30grp t1_province t1_10_5cat t1_conchealth t1_poverty_2cat I2 t1_interruption
mos_ss oasis cesd10_resc;
run;

The following error message reads:  

ERROR: Variable t1_30grp is not in the PARMS= data set.

 

I understand that this has been solved for other users by specifying the correct (classvar=) option, however I am unsure of what this is for the command "proc surveyreg"?

 

Thanks in advance. 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
SAS_Rob
SAS Employee

Notice that in the example I posted that I do not have the CLASS statement in the MIANALYZE step.  Instead, because the variable and the level are now concatenated with the COMPRESS function, the variables names on the MODELEFFECTS statement are also different.  It might help to simply Proc PRINT the PARMS= data set after you use the COMPRESS function and then the variables names contained in the variable PARAMETER will be the same ones you use on the MODELEFFECTS statement.

View solution in original post

6 REPLIES 6
gcjfernandez
SAS Employee
Because you are using complex survey design, you need to consider Proc Surveyimpute for imputing missing values and then use survey procs to analyze the survey data.
Try SAS Surveyimpute method=FEFI (Efficient Fractional Imputation (FEFI). Please refer the paper: https://support.sas.com/resources/papers/proceedings16/SAS3520-2016.pdf
stodo53
Fluorite | Level 6

Hi,

 

Thanks for your reply! I have been following the textbook "Multiple Imputation of Missing Data Using SAS" by Berglund and Heeringa. They have written a full chapter on multiple imputation for the analysis of complex sample survey data and do not mention having to use "procsurvey impute." So, I guess I am just confused as to why I am having these errors if this code was indeed written for complex survey data. I was using the FCS method. 

SAS_Rob
SAS Employee

It would be helpful to see the steps in between the MI and MIANALYZE as well, but it might well be that the problem is because of the way that SURVEYREG codes CLASS variables, it is necessary to remove all blanks from the variable Parameter before using MIANALYZE.  Below is a simple example.

 

/*This assumes that the imputation has already been done*/
data farms;
do _imputation_=1 to 2;
do state=1 to 2;
do region=1 to 3;
do rep=1 to 5;
farmarea=ceil(ranuni(323)*100);
cornyield=.66+.95*state+.65*farmarea+rannor(3214);
weight=ceil(ranuni(0)*10);
output;
end;
end;
end;
end;

 

proc surveyreg data=Farms;
by _imputation_;
class region;
strata State ;
model CornYield = region FarmArea /solution;
weight Weight;
ods output parameterestimates=parms;
run;

 

data parms;
set parms;
parameter=compress(parameter);

run;


proc mianalyze parms=parms;
modeleffects intercept region1 region2 farmarea;
run;

 

The WARNING message from MI regarding the non-existence of the ML estimates for the LOGISTIC method also may cause a problem that merits your attention.  You can try following the suggestion regarding the LIKELIHOOD=AUGMENTED option or simplify the logistic model itself or use the DISCRIM method for all the CLASS variables.

 

stodo53
Fluorite | Level 6

Hi Rob,

 

I really appreciate your reply; I have been troubleshooting this issue for a while and have not had any luck...  

 

I have tried adding the additional datastep to no avail. Additionally, when I substituted the "discrim" method for all class variables, I was getting additional error messages (e.g, "WARNING: The covariates are not specified in an FCS discriminant method for variable
t1_poverty_2cat, only remaining continuous variables will be used as covariates with
the default CLASSEFFECTS=EXCLUDE option.") So, changing the function did get rid of the initial error message regarding the non existence of the ML estimates, however, this new error message came up for each class variable. 

 

Here is my full code:

 

*Proc MI imputation;
proc mi data=combined seed=1180431796 nimpute=10 out=combined_imp_fcs;
class t1_30grp t1_province t1_10_5cat t1_conchealth t1_poverty_2cat I2 t1_interruption;
fcs nbiter=10 logistic(t1_conchealth/details) logistic(t1_30grp) logistic(t1_poverty_2cat) regression(oasis) regression(cesd10_resc);
var covid_weights t1_province t1_10_5cat I2 t1_interruption mos_ss t1_cesd t1_oasis t1_conchealth t1_30grp oasis
cesd10_resc t1_poverty_2cat;
run;

 

*Proc surveyreg;
proc surveyreg data=combined_imp_fcs;
weight covid_weights;
domain include;
class t1_30grp (ref='0') t1_province (ref='1') t1_10_5cat (ref='1') t1_conchealth (ref='0') t1_poverty_2cat (ref='0') I2 (ref='1') t1_interruption (ref='4');
model t1_oasis= t1_province t1_10_5cat I2 t1_interruption mos_ss t1_conchealth t1_30grp oasis cesd10_resc t1_poverty_2cat / solution;
by _imputation_ ;
ods output parameterestimates = regparms;
run;

 

* This step is required for PROC MIANALYZE to correctly combine the results within these groupings;
proc sort data=regparms;
by include _imputation_;
run;

 

data regparms2;
set regparms;
parameter=compress(parameter);
run;

 

*Proc mianalyze;
proc mianalyze parms=regparms2;
class t1_30grp t1_province t1_10_5cat t1_conchealth t1_poverty_2cat I2 t1_interruption;
by include;
modeleffects intercept t1_province t1_10_5cat I2 t1_interruption mos_ss t1_conchealth t1_30grp oasis cesd10_resc t1_poverty_2cat;
run;

 

The proc mianalyze still has the same error message: "ERROR: Variable t1_30grp is not in the PARMS= data set."

SAS_Rob
SAS Employee

Notice that in the example I posted that I do not have the CLASS statement in the MIANALYZE step.  Instead, because the variable and the level are now concatenated with the COMPRESS function, the variables names on the MODELEFFECTS statement are also different.  It might help to simply Proc PRINT the PARMS= data set after you use the COMPRESS function and then the variables names contained in the variable PARAMETER will be the same ones you use on the MODELEFFECTS statement.

stodo53
Fluorite | Level 6

Hi Rob,

 

That solved the issue. For the MI ANALYZE step, it seems that you cannot use a class statement after using proc surveyreg and instead have to list all categorical variables in the modeleffects statement (except the reference categories). 

 

Thanks!

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 2242 views
  • 1 like
  • 3 in conversation