SAS Programming

DATA Step, Macro, Functions and more
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;

 

 

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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
  • 1318 views
  • 1 like
  • 2 in conversation