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.
Sikcion
Fluorite | Level 6

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;

截屏2023-07-27 下午7.05.34.png

截屏2023-07-27 下午7.11.44.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
SASKiwi
PROC Star

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;

View solution in original post

3 REPLIES 3
SASKiwi
PROC Star

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;
Sikcion
Fluorite | Level 6

It works! Thank you!!

ballardw
Super User

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-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
  • 3 replies
  • 1763 views
  • 0 likes
  • 3 in conversation