BookmarkSubscribeRSS Feed
stodo53
Fluorite | Level 6

Hi all,

 

I am trying to run PROC MIANALYZE with the covb option specified, however, I am running into an error message (see attached). Combined_imp_fcs is my imputed dataset. I already tried the following suggestion , to no avail. I would appreciate any help with troubleshooting this error message. 

/* SAS PROC SURVEYREG with PROC MIANALYZE to do Multivariate Tests*/
proc surveyreg data=combined_imp_fcs ;
weight covid_weights ;
by _imputation_ ;
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 covb;
ods output parameterestimates=outparms  covb=outcovb ;
run ;
proc print data=outparms ;
run;
proc print data=outcovb ;
run ;

title "Compressed Parameter" ;
* modify name of categorical variables to match outcovb ;
data outparms1 ;
set outparms ;
parameter=compress(parameter) ;
run ;
proc print ;
run ;
data outcovb1;
set outcovb ;
parameter=compress(parameter) ;
t1_30grp0=t1_30grp_0;
t1_30grp1=t1_30grp_1; 
t1_30grp2=t1_30grp_2; 
t1_province1=t1_province_1; 
t1_province2=t1_province_2; 
t1_province3=t1_province_3; 
t1_province4=t1_province_4; 
t1_province5=t1_province_5;
t1_province6=t1_province_6; 
t1_province7=t1_province_7;
t1_province8=t1_province_8; 
t1_province9=t1_province_9;
t1_province10=t1_province_10; 
t1_province11=t1_province_11; 
t1_10_5cat1=t1_10_5cat_1; 
t1_10_5cat2=t1_10_5cat_2; 
t1_10_5cat3=t1_10_5cat_3; 
t1_10_5cat4=t1_10_5cat_4; 
t1_10_5cat5=t1_10_5cat_5;
t1_conchealth0=t1_conchealth_0;
t1_conchealth1=t1_conchealth_1; 
t1_conchealth2=t1_conchealth_2; 
t1_conchealth3=t1_conchealth_3;
t1_poverty_2cat0=t1_poverty_2cat_0; 
t1_poverty_2cat1=t1_poverty_2cat_1; 
i21=i2_1;
i22=i2_2; 
i23=i2_3; 
i24=i2_4;
i25=i2_5;
t1_interruption1=t1_interruption_1;
t1_interruption2=t1_interruption_2; 
t1_interruption3=t1_interruption_3;
t1_interruption4=t1_interruption_4;
run ;
title "Compressed Covb Parameter" ;
proc print ;
run ;

proc sort data=outparms1;
by include _imputation_;
run;

/*use OUTPARMS and OUTCOVB in PROC MIANALYZE for Multivariate Test */
proc mianalyze parms=outparms1 covb=outcovb1;
by include;
modeleffects intercept t1_30grp1 t1_30grp2 t1_province2 t1_province3 t1_province4 t1_province5 t1_province6 t1_province7
t1_province8 t1_province9 t1_province10 t1_province11 t1_10_5cat2 t1_10_5cat3 t1_10_5cat4 t1_10_5cat5
t1_conchealth1 t1_conchealth2 t1_conchealth3 t1_poverty_2cat1 i22 i23 t1_interruption1 t1_interruption2 t1_interruption3
mos_ss oasis cesd10_resc ;
  test t1_30grp1, t1_30grp2, t1_province2, t1_province3, t1_province4, t1_province5, t1_province6, t1_province7,
t1_province8, t1_province9, t1_province10, t1_province11, t1_10_5cat2, t1_10_5cat3, t1_10_5cat4, t1_10_5cat5,
t1_conchealth1, t1_conchealth2, t1_conchealth3, t1_poverty_2cat1, i22, i23, t1_interruption1, t1_interruption2, t1_interruption3,
mos_ss, oasis, cesd10_resc/ mult;
run ;

 

saratodorovic_1-1622221307876.png

7 REPLIES 7
SAS_Rob
SAS Employee

Rather than doing all the renaming and using the COMPRESS function, it will be easier to get them to match if you use the TRANWRD function instead.  The reason why this is necessary is because SURVEYREG names the columns in the COVB matrix using _ where the spaces are in the Parameter.

Below is an example showing what I mean.

 

/*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 covb;
weight Weight;
ods output parameterestimates=parms covb=covb;
run;
/*Because of the way that SURVEYREG codes CLASS variables it is necessary to
remove all blanks from the variable Parameter*/
data parms;
set parms;
parameter=tranwrd(strip(parameter),' ','_');
run;

data covb;
set covb;
parameter=tranwrd(strip(parameter),' ','_');
run;

proc mianalyze parms=parms covb=covb mult;
modeleffects intercept region_1 region_2 farmarea;
test region_1=region_2;
run;

 

 

 

stodo53
Fluorite | Level 6

Thanks for letting me know how to simplify that. However, I am still receiving the same error messages even after adjusting my code to your example. 

 

"ERROR: Within-imputation COVB matrix is not symmetric for _Imputation_= 2 in the input COVB=
data set"

SAS_Rob
SAS Employee

Can you post the whole LOG/code?

stodo53
Fluorite | Level 6
*Proc MI imputation;
proc mi data=combined seed=1180431796 nimpute=20 out=combined_imp_fcs;
 class t1_30grp t1_province t1_10_5cat t1_conchealth t1_poverty_2cat I2 t1_interruption;
 fcs logistic(t1_conchealth= t1_province t1_10_5cat I2 t1_interruption mos_ss t1_cesd t1_oasis t1_30grp oasis 
 cesd10_resc t1_poverty_2cat cesd10_resc*t1_interruption oasis*t1_interruption/details); 
 fcs logistic(t1_30grp= t1_province t1_10_5cat I2 t1_interruption mos_ss t1_cesd t1_oasis t1_conchealth oasis 
 cesd10_resc t1_poverty_2cat cesd10_resc*t1_interruption oasis*t1_interruption); 
 fcs discrim(t1_poverty_2cat=t1_province t1_10_5cat I2 t1_interruption mos_ss t1_cesd t1_oasis t1_conchealth t1_30grp oasis 
 cesd10_resc/classeffects=include); 
 fcs regression(oasis=t1_province t1_10_5cat I2 t1_interruption mos_ss t1_cesd t1_oasis t1_conchealth t1_30grp 
 cesd10_resc t1_poverty_2cat cesd10_resc*t1_interruption); 
 fcs regression(cesd10_resc=t1_province t1_10_5cat I2 t1_interruption mos_ss t1_cesd t1_oasis t1_conchealth t1_30grp oasis 
 t1_poverty_2cat oasis*t1_interruption);
 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;

/* SAS PROC SURVEYREG with PROC MIANALYZE to do Multivariate Tests*/
proc surveyreg data=combined_imp_fcs ;
weight covid_weights ;
by _imputation_ ;
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 covb;
ods output parameterestimates=outparms  covb=outcovb ;
run ;

data outparms1;
set outparms;
parameter=tranwrd(strip(parameter),' ','_');
run;

data outcovb1;
set outcovb;
parameter=tranwrd(strip(parameter),' ','_');
run;

proc print data=outcovb1;
run;

proc sort data=outparms1;
by include _imputation_;
run;
proc sort data=outcovb1;
by _imputation_;
run;

/*use OUTPARMS and OUTCOVB in PROC MIANALYZE for Multivariate Test */
proc mianalyze parms=outparms1 covb=outcovb1;
by include;
modeleffects intercept t1_30grp_1 t1_30grp_2 t1_province_2 t1_province_3 t1_province_4 t1_province_5 t1_province_6 t1_province_7
t1_province_8 t1_province_9 t1_province_10 t1_province_11 t1_10_5cat_2 t1_10_5cat_3 t1_10_5cat_4 t1_10_5cat_5
t1_conchealth_1 t1_conchealth_2 t1_conchealth_3 t1_poverty_2cat_1 i2_2 i2_3 t1_interruption_1 t1_interruption_2 t1_interruption_3
mos_ss oasis cesd10_resc ;
  test t1_30grp_1, t1_30grp_2, t1_province_2, t1_province_3, t1_province_4, t1_province_5, t1_province_6, t1_province_7,
t1_province_8, t1_province_9, t1_province_10, t1_province_11, t1_10_5cat_2, t1_10_5cat_3, t1_10_5cat_4, t1_10_5cat_5,
t1_conchealth_1, t1_conchealth_2, t1_conchealth_3, t1_poverty_2cat_1, i2_2, i2_3, t1_interruption_1, t1_interruption_2, t1_interruption_3,
mos_ss, oasis, cesd10_resc/ mult;
run ;

 

Log1.png

Log2.png

  

SAS_Rob
SAS Employee

Looks like you didn't sort the COVB data set the same way as the PARMS.  Try fixing that and see if the issue goes away.

 

stodo53
Fluorite | Level 6
proc sort data=outparms1;
by _imputation_;
run;
proc sort data=outcovb1;
by _imputation_;
run;

saratodorovic_0-1622231456618.png

The code above produced this error term. When I try to sort them both by _imputation_ and include, it says that the  variable include is not found in outcovb1. 

SAS_Rob
SAS Employee

I think you need to sort them both by INCLUDE and _IMPUTATION_.

 

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 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
  • 7 replies
  • 1564 views
  • 0 likes
  • 2 in conversation