BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Satori
Quartz | Level 8

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?

 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

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;
--
Paige Miller

View solution in original post

2 REPLIES 2
EyalGonen
Lapis Lazuli | Level 10

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/

 

PaigeMiller
Diamond | Level 26

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;
--
Paige Miller

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 2 replies
  • 544 views
  • 2 likes
  • 3 in conversation