Hello,
I have run MI with 30 imputations and would like to calculate median estimates among subgroups. Using the code below, I was able to get median estimates, but I cannot seem to output the subgroup estimates.
PROC SORT DATA=for_gee;
BY _imputation_;
RUN;
PROC SURVEYMEANS DATA=for_gee MEDIAN;
BY _imputation_;
WHERE months_post = .;
DOMAIN sex;
VAR igg_value_new;
ODS OUTPUT QUANTILES=stats1;
RUN;
I get this (one of the imputations):
sex | Variable | Percentile |
| Estimate | Std | 95% Lower CL | 95% Upper CL |
Female | igg_value_new | 50 | Median | 0.968816 | 0.009923 | 0.94935319 | 0.98827979 |
Male | igg_value_new | 50 | Median | 0.980282 | 0.013516 | 0.95377236 | 1.00679102 |
In the output, I am only getting one estimate per imputation (0.972689). Is there a way to change the output to include both estimates?
Thank you!
If you want the quantiles by Domain in a data set then you use: ods output DOMAINQUANTILES =stat1;
When you see information in the RESULTS window that does not make it into your output data set you should use ODS TRACE to show which sources are used. For example which shows two output objects containing quantiles, Quantiles and Domainquantiles. The linked solution did not do DOMAIN analysis so did not need the Domainquantiles.
71 ods trace on; 72 PROC SURVEYMEANS DATA=sashelp.class MEDIAN q1 q3; 73 /*BY _imputation_;*/ 74 /*WHERE months_post = .;*/ 75 ODS OUTPUT QUANTILES=stats1; 76 DOMAIN sex; 77 VAR height; 78 RUN; NOTE: Writing HTML Body file: sashtml1.htm Output Added: ------------- Name: Summary Label: Data Summary Template: Stat.SurveyMeans.Factoid Path: Surveymeans.Summary ------------- Output Added: ------------- Name: Statistics Label: Statistics Template: Stat.SurveyMeans.Statistics Path: Surveymeans.Statistics ------------- Output Added: ------------- Name: Quantiles Label: Quantiles Template: Stat.SurveyMeans.Quantiles Path: Surveymeans.Quantiles ------------- Output Added: ------------- Name: DomainQuantiles Label: Quantiles for Sex Domains Template: Stat.SurveyMeans.DomainQuantiles Path: Surveymeans.DomainAnalysis.DomainQuantiles ------------- NOTE: The data set WORK.STATS1 has 3 observations and 10 variables. NOTE: PROCEDURE SURVEYMEANS used (Total process time): real time 0.47 seconds cpu time 0.26 seconds 79 80 ods trace off;
What defines your subgroups? If mean that you have another variable like age that you want combinations of Sex and Age considered then add them to the Domain such as
Domain sex sex*age age.
This will give the results considering sex only, age within sex and age only. You can provide combinations for grouping by using ( ) similar to the Tables statement in proc freq.
So you can combine groups of variables with statements like
Domain (var1 var2 var3) * (vara varb varc);
to provide var1*vara var1*varb var1*varc var2*vara etc.
My subgroups are male and female, but I only get one estimate instead of two in the output.
Thank you!
@cmendoza87 wrote:
My subgroups are male and female, but I only get one estimate instead of two in the output.
Thank you!
Please look closely at your log. Do you see a statement anything like this?
WARNING: Output 'QUANTILES' was not created. Make sure that the output object name, label, or path is spelled correctly. Also, verify that the appropriate procedure options are used to produce the requested output object. For example, verify that the NOPRINT option is not used.
Now, go back to your Surveymeans statement and look at the requested statistics.
You do not show any request for any quantile statistic so you only get the n, m, std error and confidence limits.
If you want a quantile then you have to specify it on the Proc Statement such as Q1 Q3 Deciles Quartiles Median or other specific quantile wanted.
Since you aren't using any complex weighting scheme, why suveymeans?
Sorry for the delay in responding. I do not see that message in the log. This is what I see:
NOTE: The input data set is subset by WHERE, OBS, or FIRSTOBS. This provides a completely separate
analysis of the subset. It does not provide a statistically valid subpopulation or domain
analysis, where the total number of units in the subpopulation is not known with certainty. If
you want a domain analysis, you should include the DOMAIN variables in a DOMAIN statement.
NOTE: The BY statement provides completely separate analyses of the BY groups. It does not provide a
statistically valid subpopulation or domain analysis, where the total number of units in the
subpopulation is not known with certainty. If you want a domain analysis, you should include
the DOMAIN variables in a DOMAIN statement.
NOTE: The data set WORK.STATS1 has 30 observations and 10 variables.
I included MEDIAN in the proc statement.
I am using surveymeans because I am trying to get median values for the imputed data and I saw this post: Solved: Multiple imputation - caculating medians - SAS Support Communities
I am certainly open to other options.
Thank you!
If you want the quantiles by Domain in a data set then you use: ods output DOMAINQUANTILES =stat1;
When you see information in the RESULTS window that does not make it into your output data set you should use ODS TRACE to show which sources are used. For example which shows two output objects containing quantiles, Quantiles and Domainquantiles. The linked solution did not do DOMAIN analysis so did not need the Domainquantiles.
71 ods trace on; 72 PROC SURVEYMEANS DATA=sashelp.class MEDIAN q1 q3; 73 /*BY _imputation_;*/ 74 /*WHERE months_post = .;*/ 75 ODS OUTPUT QUANTILES=stats1; 76 DOMAIN sex; 77 VAR height; 78 RUN; NOTE: Writing HTML Body file: sashtml1.htm Output Added: ------------- Name: Summary Label: Data Summary Template: Stat.SurveyMeans.Factoid Path: Surveymeans.Summary ------------- Output Added: ------------- Name: Statistics Label: Statistics Template: Stat.SurveyMeans.Statistics Path: Surveymeans.Statistics ------------- Output Added: ------------- Name: Quantiles Label: Quantiles Template: Stat.SurveyMeans.Quantiles Path: Surveymeans.Quantiles ------------- Output Added: ------------- Name: DomainQuantiles Label: Quantiles for Sex Domains Template: Stat.SurveyMeans.DomainQuantiles Path: Surveymeans.DomainAnalysis.DomainQuantiles ------------- NOTE: The data set WORK.STATS1 has 3 observations and 10 variables. NOTE: PROCEDURE SURVEYMEANS used (Total process time): real time 0.47 seconds cpu time 0.26 seconds 79 80 ods trace off;
This worked, thank you!! I feel kind of dumb for not having tried that haha thank you for your help with this!
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!
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.