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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 342 views
  • 0 likes
  • 2 in conversation