- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I'm trying to use PROC SURVEYMEANS to analyze continuous variables from a weighted survey (i.e., NHANES). This article has been helpful.
I want to look at age (continuous) by year, in a subpopulation defined by a flag variable (i.e., flag_1).
proc surveymeans DATA=nhanes.go nomcar;
STRATUM sdmvstra;
CLUSTER sdmvpsu;
WEIGHT wtmec10yr_09_18;
/* DOMAIN: used instead of the WHERE or BY statement to provide analyses of subgroups. */
domain flag_1 year;
var age_yrs;
run;
When both flag_1 and year are included in the DOMAIN statement, I get the mean of age_yrs by flag_1 (0, 1) and by year, but not by both (see screenshot).
I am seeking the mean of age_yrs by year when flag_1 = 1.
I've tried adding a CLASS statement to no avail.
Thanks for any suggestions.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
From the documentation:
If two or more variables are joined by asterisks (*), then every possible combination of levels of these variables determines a domain
If you use this you should get the desired result.
Domain flag_1 * year;
If you want the individual domains and the combined use:
Domain flag_1 * year flag_1 year;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
From the documentation:
If two or more variables are joined by asterisks (*), then every possible combination of levels of these variables determines a domain
If you use this you should get the desired result.
Domain flag_1 * year;
If you want the individual domains and the combined use:
Domain flag_1 * year flag_1 year;