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 using proc tabulate to create tables and I have code that works to make the table I want.

 

Now I just want to add a format so that any cells with values less than or equal to 10 have 

≤10 in the cell.  

 

This is the code I used to make my format:

 

value numb 0-10 = "<=10";

 

And this is my proc tabulate code:

 

proc tabulate data=top25wvars format=numb. ;
class diag1ccs / order=freq;
class age_3cat;
table diag1ccs=' ',
(all='All' age_3cat=' ') * n=' '
/box='Top 25 CCS diagnoses'
;
title "Iowa top 25 diagnoses";
run;
title;

 

When I added the format=numb. part, it does put the <=10 in the appropriate cells.  However, now it is adding some kind of scientific notation to the larger numbers that I don't want (see below).  How do I get the <=10 inserted but have it leave the larger numbers alone?

 

Top 25 CCS diagnoses

All

0 years

1-17 years

18-109 years

Abdominal pain

56E3

44

7487

49E3

Other upper respiratory infections

53E3

5922

23E3

24E3

Nonspecific chest pain

49E3

<=10

1503

48E3

 

Thanks!

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

@hein68 wrote:

Hello.  I'm using proc tabulate to create tables and I have code that works to make the table I want.

 

Now I just want to add a format so that any cells with values less than or equal to 10 have 

≤10 in the cell.  

 

This is the code I used to make my format:

 

value numb 0-10 = "<=10";

 

And this is my proc tabulate code:

 

proc tabulate data=top25wvars format=numb. ;
class diag1ccs / order=freq;
class age_3cat;
table diag1ccs=' ',
(all='All' age_3cat=' ') * n=' '
/box='Top 25 CCS diagnoses'
;
title "Iowa top 25 diagnoses";
run;
title;

 

When I added the format=numb. part, it does put the <=10 in the appropriate cells.  However, now it is adding some kind of scientific notation to the larger numbers that I don't want (see below).  How do I get the <=10 inserted but have it leave the larger numbers alone?

 

Top 25 CCS diagnoses

All

0 years

1-17 years

18-109 years

Abdominal pain

56E3

44

7487

49E3

Other upper respiratory infections

53E3

5922

23E3

24E3

Nonspecific chest pain

49E3

<=10

1503

48E3

 

Thanks!

 


Since you did not specify either a default length or "other" format the length of the format has been defined to be 4 characters and so the "best" format is used to display other values.

 

Try modifying your value statement as

value numb 
0-10 = "<=10"
other = [best7.]
;

to provide a different format for values outside of the specific range of interest.

Note that referencing another format in this manner is one of the places that square brackets [ ] must be used. ( ) will not work.

Or use the (default= ) option to set a longer default width for display.

View solution in original post

2 REPLIES 2
ballardw
Super User

@hein68 wrote:

Hello.  I'm using proc tabulate to create tables and I have code that works to make the table I want.

 

Now I just want to add a format so that any cells with values less than or equal to 10 have 

≤10 in the cell.  

 

This is the code I used to make my format:

 

value numb 0-10 = "<=10";

 

And this is my proc tabulate code:

 

proc tabulate data=top25wvars format=numb. ;
class diag1ccs / order=freq;
class age_3cat;
table diag1ccs=' ',
(all='All' age_3cat=' ') * n=' '
/box='Top 25 CCS diagnoses'
;
title "Iowa top 25 diagnoses";
run;
title;

 

When I added the format=numb. part, it does put the <=10 in the appropriate cells.  However, now it is adding some kind of scientific notation to the larger numbers that I don't want (see below).  How do I get the <=10 inserted but have it leave the larger numbers alone?

 

Top 25 CCS diagnoses

All

0 years

1-17 years

18-109 years

Abdominal pain

56E3

44

7487

49E3

Other upper respiratory infections

53E3

5922

23E3

24E3

Nonspecific chest pain

49E3

<=10

1503

48E3

 

Thanks!

 


Since you did not specify either a default length or "other" format the length of the format has been defined to be 4 characters and so the "best" format is used to display other values.

 

Try modifying your value statement as

value numb 
0-10 = "<=10"
other = [best7.]
;

to provide a different format for values outside of the specific range of interest.

Note that referencing another format in this manner is one of the places that square brackets [ ] must be used. ( ) will not work.

Or use the (default= ) option to set a longer default width for display.

hein68
Quartz | Level 8

This is great, thanks!