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

Hello.

 

The class statement doesn't work in the syntax below. 

PROC SURVEYMEANS Data=health varmethod=brr mean clm;
CLASS sex agegroup;
REPWEIGHTS Rweight1-Rweight500;
VAR Cause;
WEIGHT TWeight ;
ods output Statistics=MyStat1 (keep= VarLevel Mean LowerCLMean StdErr UpperCLMean sex agegroup);
run; 

The output contents only the total estimations. 

Any helps will be appreciated. 

 

Thank you!  

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

If you want to have a summary of the variable Cause for levels of the variables Sex and Agegroup then you want to use a DOMAIN statement in Surveymeans.

 

Compare the output for these two calls that you can run as you should have the SAS supplied SASHELP.CLASS data set:

proc surveymeans data=sashelp.class;
   class sex age;
   var height;
run;

proc surveymeans data=sashelp.class;
   domain sex age;
   var height;
run;

And compare these for the intended use of CLASS when you want analysis of the levels of a variable.

proc surveymeans data=sashelp.class;
   var   age;
run;
proc surveymeans data=sashelp.class;
   class age;
   var   age;
run;

View solution in original post

9 REPLIES 9
Reeza
Super User
Does your log show any error? Mine states that the BRR method requires a STRATA statement? Is that perhaps what you need to be using instead of CLASS?
altadata1
Calcite | Level 5

Hi. I don't receive any errors, except the warning: "The variable diverse in the Drop, Keep, or Rename list has never been referenced."

 

altadata1
Calcite | Level 5

Sorry, i meant the variable "sex" . Thank you. 

ballardw
Super User

If you want to have a summary of the variable Cause for levels of the variables Sex and Agegroup then you want to use a DOMAIN statement in Surveymeans.

 

Compare the output for these two calls that you can run as you should have the SAS supplied SASHELP.CLASS data set:

proc surveymeans data=sashelp.class;
   class sex age;
   var height;
run;

proc surveymeans data=sashelp.class;
   domain sex age;
   var height;
run;

And compare these for the intended use of CLASS when you want analysis of the levels of a variable.

proc surveymeans data=sashelp.class;
   var   age;
run;
proc surveymeans data=sashelp.class;
   class age;
   var   age;
run;
altadata1
Calcite | Level 5

Thank you for the reply. Why do i need to use "Domain" instead of Class. Domain makes a subpopulation, while what I need is to create the estimations by the categories of the variable in CLASS - That's what CLASS statement does. 

ballardw
Super User

Please read your initial message carefully. You do not say anything about what you actually wanted for output just claimed that "class doesn't work".

 

I went with a suggestion of DOMAIN as that is a frequent request for that type of output and one of the possible interpretations because of the way CLASS works in other procedures such as MEANS/Summary, Tabulate and others.

 

So you needed to add the CLASS variables to the VAR statement to get the levels of those variables. I did show how to do that as well.

 

 

Hello.

 

The class statement doesn't work in the syntax below. 

PROC SURVEYMEANS Data=health varmethod=brr mean clm;
CLASS sex agegroup;
REPWEIGHTS Rweight1-Rweight500;
VAR Cause;
WEIGHT TWeight ;
ods output Statistics=MyStat1 (keep= VarLevel Mean LowerCLMean StdErr UpperCLMean sex agegroup);
run; 

The output contents only the total estimations. 

Any helps will be appreciated. 

 

Thank you!  

altadata1
Calcite | Level 5

Thank you for your response, and I apologize for not explaining it clearly at the beginning.

I was concerned that the "domain" statement might function like the "by" statement, treating each subgroup independently. However, it seems that is not the case. So, I will use the "domain" statement. Thank you very much!

I still don't understand why the "class" statement doesn't work. Is the "class" statement only for categorical variables?

Thank you! 

ballardw
Super User

If a numeric variable appears on the VAR statement then it will only have the requested statistics mean or what ever. However when a variable appears on the CLASS statement and the VAR statement then levels of the variable are summarized. Class is used to force categorical behavior when you want it but only for variables on the VAR statement.

altadata1
Calcite | Level 5

Thank you so much for the explanation. 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 9 replies
  • 345 views
  • 2 likes
  • 3 in conversation