BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
FarazA_Qureshi
Calcite | Level 5

While PROC FORMAT helps in dividing dataset in desired categories with PUT() as:

PROC FORMAT;

value Buckets

low -< 1 = 'Bucket 1'

1 -< 30 = 'Bucket 2'

30 -< 60 = 'Bucket 3'

60 -< 90 = 'Bucket 4'

90 -< 120 = 'Bucket 5'

120 -< 150 = 'Bucket 6'

150 -< 180 = 'Bucket 7'

180 -< 210 = 'Bucket 8'

210 -< 240 = 'Bucket 9'

240 -< 270 = 'Bucket 10'

270 -< 300 = 'Bucket 11'

300 -< 330 = 'Bucket 12'

330 -< 360 = 'Bucket 13'

360 - High = 'Bucket 14'

;

run;

Could a dataset be returned to represent all the buckets declared above even no entry exists in the same. Something like:

Bucket 13615833
Bucket 211899480
Bucket 3.
Bucket 41340713
Bucket 52618488
Bucket 6.
Bucket 78479480
Bucket 811619361
Bucket 9.
Bucket 108103834
Bucket 1111894685
Bucket 12.
Bucket 13300642
Bucket 141373049

Where . represents the bucket to be having no amount belonging to the same.

Thanx in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
data_null__
Jade | Level 19

PRELOADFMT is the option you need when you have a value format as in your example.  It can be used in SUMMARY/MEANS, REPORT and TABULATE

data bucker;
   x = 0;
  
run;
PROC FORMAT;
  
value Buckets
       low -<
1 = 'Bucket 1'
       
1 -< 30 = 'Bucket 2'
      
30 -< 60 = 'Bucket 3'
      
60 -< 90 = 'Bucket 4'
      
90 -< 120 = 'Bucket 5'
     
120 -< 150 = 'Bucket 6'
     
150 -< 180 = 'Bucket 7'
     
180 -< 210 = 'Bucket 8'
     
210 -< 240 = 'Bucket 9'
     
240 -< 270 = 'Bucket 10'
     
270 -< 300 = 'Bucket 11'
     
300 -< 330 = 'Bucket 12'
     
330 -< 360 = 'Bucket 13'
     
360 - High = 'Bucket 14'
      ;
   run;
proc summary data=bucker nway completetypes;
  
class x / preloadfmt;
  
format x buckets.;
  
output out=counts;
   run;
proc print;
  
run;

Message was edited by: data _null_ for no particular reason.

View solution in original post

1 REPLY 1
data_null__
Jade | Level 19

PRELOADFMT is the option you need when you have a value format as in your example.  It can be used in SUMMARY/MEANS, REPORT and TABULATE

data bucker;
   x = 0;
  
run;
PROC FORMAT;
  
value Buckets
       low -<
1 = 'Bucket 1'
       
1 -< 30 = 'Bucket 2'
      
30 -< 60 = 'Bucket 3'
      
60 -< 90 = 'Bucket 4'
      
90 -< 120 = 'Bucket 5'
     
120 -< 150 = 'Bucket 6'
     
150 -< 180 = 'Bucket 7'
     
180 -< 210 = 'Bucket 8'
     
210 -< 240 = 'Bucket 9'
     
240 -< 270 = 'Bucket 10'
     
270 -< 300 = 'Bucket 11'
     
300 -< 330 = 'Bucket 12'
     
330 -< 360 = 'Bucket 13'
     
360 - High = 'Bucket 14'
      ;
   run;
proc summary data=bucker nway completetypes;
  
class x / preloadfmt;
  
format x buckets.;
  
output out=counts;
   run;
proc print;
  
run;

Message was edited by: data _null_ for no particular reason.

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
  • 1 reply
  • 516 views
  • 0 likes
  • 2 in conversation