BookmarkSubscribeRSS Feed
Ronein
Meteorite | Level 14

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;
3 REPLIES 3
PaigeMiller
Diamond | Level 26

In the first example, I get levels followed by the frequency table (including frequency, percent, cumulative frequency, cumulative percent). Show us what you see.

--
Paige Miller
Kathryn_SAS
SAS Employee

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.

ballardw
Super User

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.

 

The FREQ Procedure
Number of Variable
Levels
Variable Levels
Origin 3


Origin Frequency Percent Cumulative
Frequency
Cumulative
Percent
Asia 158 36.92 158 36.92
Europe 123 28.74 281 65.65
USA 147 34.35 428 100.00

SAS Innovate 2025: Register Now

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!

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
  • 781 views
  • 0 likes
  • 4 in conversation