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

Appreciate if any one of you help me understand the purpose of nway and missing option in proc means. My understanding is, it will delete the records if the values of class variable is missing.

 

proc means data=stack nway noprint missing;
class SNAP_DATE loc loc_name bu ip_code matrl_typ  storage_loc material ;
output out=MB_SUMMARY(drop=_:) sum(UNRSTR_QTY_DOL UNRSTR_QTY_UL)=;
run;
 
1 ACCEPTED SOLUTION
4 REPLIES 4
Kurt_Bremser
Super User

As always, Maxim 1: Read the Documentation.

 

From the documentation of the PROC MEANS Statement:

NWAY

specifies that the output data set contain only statistics for the observations with the highest _TYPE_ and _WAY_ values. When you specify class variables, NWAY corresponds to the combination of all class variables.

Interaction If you specify a TYPES statement or a WAYS statement, then PROC MEANS ignores this option.
See Output Data Set
Computing Output Statistics with Missing Class Variable Values

 

which means that statistics for higher-up CLASS variables (in your example, (e.g.) the discrete values of SNAP_DATE) are not calculated, only those for the combination of all CLASS variables.

 

MISSING

considers missing values as valid values to create the combinations of class variables. Special missing values that represent numeric values (the letters A through Z and the underscore (_) character) are each considered as a separate value.

Default If you omit MISSING, then PROC MEANS excludes the observations with a missing class variable value from the analysis.
See SAS Language Reference: Concepts for a discussion of missing values that have special meaning.
Using Preloaded Formats with Class Variables

 

self-explanatory

David_Billa
Rhodochrosite | Level 12

@Kurt_Bremser Well, any thoughts to how to explain this code to R programmers in simple language?

PaigeMiller
Diamond | Level 26

You can try running PROC MEANS without these options (one at a time) and see the difference in the output. If that and the documentation still doesn't make sense, ask specific questions.

--
Paige Miller

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 4 replies
  • 19693 views
  • 3 likes
  • 3 in conversation