Dear All,
I was wondering if there is a way to display only the most frequent categories (let's say, 10) when using PROC FREQ.
proc freq data= sashelp.cars order= freq;
table make; run;
The code shows the list of car makers with their frequency. But I just would like to display this information for the top 10 carmakers. The below table is what I would like to have. Thanks in advance!
Make Frequency Percent Cumulative
FrequencyCumulative
PercentToyota 28 6.54 28 6.54 Chevrolet 27 6.31 55 12.85 Mercedes-Benz 26 6.07 81 18.93 Ford 23 5.37 104 24.30 BMW 20 4.67 124 28.97 Audi 19 4.44 143 33.41 Honda 17 3.97 160 37.38 Nissan 17 3.97 177 41.36 Chrysler 15 3.50 192 44.86 Volkswagen 15 3.50 207 48.36
You can use the MAXLEVELS= option in the TABLES statement.
proc freq data=sashelp.cars order=freq;
tables make / maxlevels=10;
One way, make a data set. Then select the observations to print:
proc freq data= sashelp.cars order= freq noprint; table make/out=work.carfreq; run; proc print data=work.carfreq(obs=10); run;
You can use the MAXLEVELS= option in the TABLES statement.
proc freq data=sashelp.cars order=freq;
tables make / maxlevels=10;
You can also use the MAXLEVELS=10 option to create a bar chart that shows the top categories. See "An easy way to make a "Top 10" table and bar chart in SAS."
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!
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.