Hello
In first example I get only Levels column.
In second example I get more columns: frequency, percent,Cum freq, Cum percent.
Why is it??
proc freq data =sashelp.cars nlevels;
tables Origin;
run;
proc freq data =sashelp.cars nlevels;
tables _ALL_;
run;
In the first example, I get levels followed by the frequency table (including frequency, percent, cumulative frequency, cumulative percent). Show us what you see.
The NLEVELS option in PROC FREQ will create a separate table regardless of how many variables you request. The number of columns in the table will depend on if the variable(s) have missing values or not. In the first case, Origin does not have missing values, so the table will only show the variable name and the number of unique levels. In the second case, where you chose all variables (or if you had chosen the Cylinders variable initially), you will see columns for Levels, Missing Levels, and Nonmissing Levels. The sum of the Missing Levels and Nonmissing Levels is Levels. There is also a column for Labels if any of the variables has a label assigned.
Here is my output for the first proc freq which has frequency, percent, cum freq and cum percent as I expected. The only thing I can think would that wouldn't do such is some other options not shown, such as an ODS Select left over from previous code.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.