Hi guys! I met a question is that
I want to use the proc means function to calculate the mean/std/N value of each category in the treatment group and visit weeks. In the result part , the table seems exactly what I want(picture1), while in the output dataset, it looks so strange that it contains some calculations of total column of weeks and treatment group(picture2 first 8 rows).
How I can get the output table without those total calculation rows? Thank you!
proc means data=ADLB01 mean std n missing;
var AVAL;
class AVISITN_1 Trt01an;
output out=visit1 mean=Mean std=SE n=N;
run;
If you add the NWAY option, it doesn't do higher summaries:
proc means data=ADLB01 mean std n missing nway;
var AVAL;
class AVISITN_1 Trt01an;
output out=visit1 mean=Mean std=SE n=N;
run;
If you add the NWAY option, it doesn't do higher summaries:
proc means data=ADLB01 mean std n missing nway;
var AVAL;
class AVISITN_1 Trt01an;
output out=visit1 mean=Mean std=SE n=N;
run;
It works! Thank you!!
This behavior of Proc Means/Summary is quite useful once you understand what goes on. The NWAY option means to only provide the highest level of the combination of variables as shown in the _type_ variable. Other options for the procedure such as the TYPES and WAYS statements are ways to request specific combinations of the class variables for the output or simple WHERE statements or dataset options.
The feature is useful as you can create summaries in one pass through the data and select the ones you want for a specific output table or analysis later.
One project I worked with provided summaries based on:
State, Region ( a combinations of Counties), County, School Type (public/private/charter, School District, School building and School Grade. One pass through summary let me create the basic summaries needed.
Then for bits of the reports that different people were interested in this created summaries of:
Statewide, Statewide by School Type, Statewide by School Grade, Statewide school type and grade,
Region, Region by School Type, Region by School Grade, Region by School type and Grade
County, (follow the pattern).
I could use the _type_ variable to select the level of report and either BY group or Proc Tabulate/Report options to create pages per subgroup as interested.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.