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;
Create the statistics with one line or each combination of all CLASS variables; consider missing values in a CLASS variable as valid.
As always, Maxim 1: Read the Documentation.
From the documentation of the PROC MEANS Statement:
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.
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
@Kurt_Bremser Well, any thoughts to how to explain this code to R programmers in simple language?
Create the statistics with one line or each combination of all CLASS variables; consider missing values in a CLASS variable as valid.
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.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.