BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
hein68
Quartz | Level 8
Hello.  I'm making a bunch of tables in proc tabulate.  I need to use a format that formats all values less than or equal to 10 with <=10 (I'm using the numb. format for this).  That works fine.  However, I also want values over 999 to have the comma7 format (so I need both formats).  This is the code that I am using (see below).  How can I get both formats applied?
 
proc tabulate data=top25adults f=comma7.;
   class diag1ccs / order=freq;
   class female aweekend dispuniform_4cat;
   table diag1ccs=' ',
         (all='Adults' female=' ' aweekend=' ' dispuniform_4cat=' ') * n=' '*f=numb.
         /box='Diagnosis' 
   ;
This is what the numb. format looks like:
 
value numb 
0-10 = "<=10"
other = [best7.]
;
 
Thanks!
  
   
run;
title;
1 ACCEPTED SOLUTION

Accepted Solutions
mkeintz
PROC Star

You can apply the COMMA. format to a sub-range just the same as you have already applied the BEST format:

 

proc format;
  value numb 
    0-10 = "<=10"
    999-HIGH=[comma8.0]
    other = [best7.];
run;

Note you don't have to list the subranges in any particular order.  So this one does the low positive number, then the high ones, and then all the others (including numbers in the middle range).

 

 

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------

View solution in original post

2 REPLIES 2
mkeintz
PROC Star

You can apply the COMMA. format to a sub-range just the same as you have already applied the BEST format:

 

proc format;
  value numb 
    0-10 = "<=10"
    999-HIGH=[comma8.0]
    other = [best7.];
run;

Note you don't have to list the subranges in any particular order.  So this one does the low positive number, then the high ones, and then all the others (including numbers in the middle range).

 

 

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
hein68
Quartz | Level 8

That worked, thanks very much!

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!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 622 views
  • 2 likes
  • 2 in conversation