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.
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;
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;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.