BookmarkSubscribeRSS Feed
Saifulinfs
Fluorite | Level 6

I wish to estimate the median of a variable (here, N_Mets1) across the quartiles of serum zinc level (variable: cat_zinc). At the same time I wish to stratify the estimate by gender (variable: sex). Below is my code. How to edit the code for PROC MIANALYZE because the current syntax outputs that shows something as if there is missing value in my sex and cat_zinc variable.

Saifulinfs_0-1688544921069.png

here is the output which shows sex=.

Saifulinfs_0-1688545489212.png

 

1 REPLY 1
SAS_Rob
SAS Employee

When you have multiple DOMAIN variables, the ODS table will contain multiple variables for each of the domains.  The missing values occur when the estimate is associated with one of the domains of the other variable.  If you examine the data set before feeding it into MIANALYZE then it will make sense.

Notice in the example below how the data set is formatted.  The first two observations are associated with DOMVAR1 (levels 1 &2) and the next two are associated with DOMVAR2 (also with 3 levels).  There are missing values for the DOMVAR1 anytime the estimate is for a level of DOMVAR2 and vice versa.

data sample;
do _imputation_=1 to 2;
do domvar1=1 to 2;
do domvar2=1 to 2;
do stratvar=1 to 2;
do rep=1 to 50;
y=.95+rannor(123);
output;
end;
end;
end;
end;end;
drop rep;
run;
proc surveymeans data=sample mean std nobs percentile=(50);
by _imputation_;
domain domvar1 domvar2;
strata stratvar;
var y ;
ods output domainquantiles=quant_imp;
run;
proc print data=quant_imp;
run;

It might be that this isn't what you intend as far as the domain analysis is concerned.  This treats each unique level of the two variables as a separate domain and thus in my example there are 5 levels.  It might be that you are expecting that the domains should be crossed, that is in my example, have 6 levels.  Then you should put the crossed variables on the DOMAIN statement.

 

proc surveymeans data=sample mean std nobs percentile=(50);
by _imputation_;
domain domvar1*domvar2;
strata stratvar;
var y ;
ods output domainquantiles=quant_imp;
run;

 

This would mean there would be no missing values in either variable. 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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
  • 1 reply
  • 636 views
  • 0 likes
  • 2 in conversation