BookmarkSubscribeRSS Feed
braam
Quartz | Level 8

Can I limit my PROC FREQ result to groups where there are more than 30 observations in the below code? In other words, I would like to just report the number of observations in SUV, Sedan, and Sports groups, respectively, using PROC FREQ. In general, I would like to know how I can add a condition to limit my result.

 


proc freq data= sashelp.cars;
	table type/ nopercent nocol; run;
Type Frequency Cumulative
Frequency
Hybrid 3 3
SUV 60 63
Sedan 262 325
Sports 49 374
Truck 24 398
Wagon 30 428

 

4 REPLIES 4
novinosrin
Tourmaline | Level 20

Not Sure directly on a PRINT output, but a workaround could be the following

 

ods output  OneWayFreqs=want(where=(Frequency>30));
proc freq data= sashelp.cars ;
	table type/ nopercent nocol; run;

proc print noobs;run;
Astounding
PROC Star

And what should appear in the Cumulative Frequency column?

braam
Quartz | Level 8
Oh, that column isn't needed.
Astounding
PROC Star

If you don't need to worry about cumulative frequency, PROC FREQ can output the right numbers directly into a data set:

 

proc freq data= sashelp.cars;
   table type / noprint out=want (where=(count > 30));
run;
proc print data=want label;
   label count = 'Frequency';
   var type count;
run;

 

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