I want to run a proc freq for a numeric variable, but since there are many values I want to group them. How can I group them?
The variable is total_assets which takes virutally all values between 0 and infinity as far as I know.
What I would like is to get a table with frequencies for the variable total_assets by grouping them into:
0-5million
5-10million
10-20million
20-50million
50-100million
>100million
Any hints on how to do this?
Use a custom format
proc format;
value assetf 0-5000000='0-5 Million'
5000000<-10000000='5-10 Million'
10000000<-20000000='10-20 Million'
/* I'm lazy, you type the rest */
;
run;
proc freq data=have;
tables total_assets;
format total_assets assetf.;
run;
You can create a user-written format that does the grouping and use it in your PROC FREQ
See example article: https://sasexamplecode.com/how-to-format-variables-in-proc-means-freq-and-tabulate-in-sas/
Use a custom format
proc format;
value assetf 0-5000000='0-5 Million'
5000000<-10000000='5-10 Million'
10000000<-20000000='10-20 Million'
/* I'm lazy, you type the rest */
;
run;
proc freq data=have;
tables total_assets;
format total_assets assetf.;
run;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.