BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
_maldini_
Barite | Level 11

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). 

Screen Shot 2022-05-24 at 2.55.59 PM.png

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.

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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;

 

 

View solution in original post

1 REPLY 1
ballardw
Super User

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;

 

 

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

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 1428 views
  • 1 like
  • 2 in conversation