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!
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;
Hi. I don't receive any errors, except the warning: "The variable diverse in the Drop, Keep, or Rename list has never been referenced."
Sorry, i meant the variable "sex" . Thank you.
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;
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.
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!
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!
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.
Thank you so much for the explanation.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.