Using the commands below, I managed to impute and then do a t-test. But it fails to get the pooled estimate because I keep getting error messages. I have already looked in the manual of ‘proc mianalyze’, but I cannot find any examples that shows the mean, standard deviation and confidence intervals.
proc mi data= b1 nimpute=25 out=out1;
var x1..Xn;
fcs regpmm(x1..Xn);
run;
proc ttest data=out1;
by _imputation_;
class classvar;
var x1..Xn;
ods output statistics=out2;
run;
Does anyone have an example of how this should be done, or is there a publication where I could extract this.
Thanks in advance.
Edmund
Below is an example that shows the necessary syntax for combining the Proc TTEST results.
/*Create a sample data set to work with*/
data test;
do grp=1 to 2;
do rep=1 to 25;
if rand('UNIFORM')>.7 then y=.;
else y=rand('NORMAL',.66*grp,1);
output;
end;
end;
run;
proc mi data=test out=mi_test seed=1;
class grp;
var grp y;
monotone regression;
run;
/*This code would work for the difference in two means*/
proc ttest data=mi_test;
class grp;
by _imputation_;
var y;
ods output statistics=ttest_ds;
run;
proc sort data=ttest_ds;
by class _imputation_;
run;
proc mianalyze data=ttest_ds;
by class;
modeleffects mean;
stderr stderr;
run;
Below is an example that shows the necessary syntax for combining the Proc TTEST results.
/*Create a sample data set to work with*/
data test;
do grp=1 to 2;
do rep=1 to 25;
if rand('UNIFORM')>.7 then y=.;
else y=rand('NORMAL',.66*grp,1);
output;
end;
end;
run;
proc mi data=test out=mi_test seed=1;
class grp;
var grp y;
monotone regression;
run;
/*This code would work for the difference in two means*/
proc ttest data=mi_test;
class grp;
by _imputation_;
var y;
ods output statistics=ttest_ds;
run;
proc sort data=ttest_ds;
by class _imputation_;
run;
proc mianalyze data=ttest_ds;
by class;
modeleffects mean;
stderr stderr;
run;
Thank you very much SAS_Rob for this quick answer.
But my problem is that I have multiple variables and in your example there is only one variable.
Is there any way to get the estimates of multiple variables along with the standard error and confidence intervals
Thanks in advance
Edmund
Thank you very much SAS_Rob for this quick answer.
But my problem is that I have multiple variables in the proc ttest (X1..Xn) (see above) and in your example there is only one variable.
Is there any way to get the estimates of multiple variables in proc mianalyze along with the standard error and confidence intervals
Thanks in advance
Edmund
You will just need to add VARIABLE to the Proc SORT and the BY statement in MIANALYZE.
data test;
do grp=1 to 2;
do rep=1 to 25;
if rand('UNIFORM')>.7 then y=.;
else y=rand('NORMAL',.66*grp,1);
if rand('UNIFORM')>.78 then y2=.;
else y2=rand('NORMAL',.3*grp,1);
output;
end;
end;
run;
proc mi data=test out=mi_test seed=1 nimpute=5;
class grp;
var grp y y2;
fcs regression;
run;
/*This code would work for the difference in two means*/
proc ttest data=mi_test;
class grp;
by _imputation_;
var y y2;
ods output statistics=ttest_ds;
run;
proc sort data=ttest_ds;
by variable class _imputation_;
run;
proc mianalyze data=ttest_ds;
by variable class;
modeleffects mean;
stderr stderr;
run;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.