Return Data Classes Even If No Records?

Accepted Solution Solved
Reply
Contributor
Posts: 51
Accepted Solution

Return Data Classes Even If No Records?

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.


Accepted Solutions
Solution
‎09-14-2013 09:22 AM
Respected Advisor
Posts: 3,799

Re: Return Data Classes Even If No Records?

Posted in reply to FarazA_Qureshi

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


All Replies
Solution
‎09-14-2013 09:22 AM
Respected Advisor
Posts: 3,799

Re: Return Data Classes Even If No Records?

Posted in reply to FarazA_Qureshi

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.

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

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