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

SAS Innovate 2025: Call for Content

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 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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