BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
DavidKaib
Fluorite | Level 6

I would like to have the output from this code apply a percentage sign.

 

proc tabulate;

class URMG Department Period;

table (department all), Period*URMG*(pctn<URMG>)/printmiss misstext='0' nocellmerge;

run;

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

You will have to create a custom format to work with the Tabulate PCT functions.

You don't say how many decimals you might want. The example below will show 1 decimal point.

proc format;
picture custpct
0 - high ='0009.9%'
;
run;

Read the documentation of the Proc Format Picture statement for details.

How to modify your code to use the format:

proc tabulate;
   class URMG Department Period;
  table (department all), 
           Period*URMG*(pctn<URMG>*f=custpct.)
          /printmiss misstext='0' nocellmerge;
run;

The *F=<some format> overrides the default format for that particular PCTN or other percent calculations.

 

View solution in original post

3 REPLIES 3
PaigeMiller
Diamond | Level 26

From the PROC TABULATE documentation, you just need to add a format.

 

format modifiers

define how to format values in cells. Use the asterisk (*) operator to associate a format modifier with the element (an analysis variable or a statistic) that produces the cells that you want to format. Format modifiers have the form

f=format

 

Tip Format modifiers have no effect on CLASS variables.
See For more information about specifying formats in tables, see Formatting Values in Tables.
Example
Sales*f=dollar8.2

 

In your case, you want the PERCENTw.d format

--
Paige Miller
ballardw
Super User

@PaigeMiller wrote:

From the PROC TABULATE documentation, you just need to add a format.

 

format modifiers

define how to format values in cells. Use the asterisk (*) operator to associate a format modifier with the element (an analysis variable or a statistic) that produces the cells that you want to format. Format modifiers have the form

f=format

 

Tip Format modifiers have no effect on CLASS variables.
See For more information about specifying formats in tables, see Formatting Values in Tables.
Example
Sales*f=dollar8.2

 

In your case, you want the PERCENTw.d format


The internal values that Tabulate applies the format to are multiplied by 100. So what would default to appearing as 15.1 will result in 1510% with wide enough Percentw.d format applied.

ballardw
Super User

You will have to create a custom format to work with the Tabulate PCT functions.

You don't say how many decimals you might want. The example below will show 1 decimal point.

proc format;
picture custpct
0 - high ='0009.9%'
;
run;

Read the documentation of the Proc Format Picture statement for details.

How to modify your code to use the format:

proc tabulate;
   class URMG Department Period;
  table (department all), 
           Period*URMG*(pctn<URMG>*f=custpct.)
          /printmiss misstext='0' nocellmerge;
run;

The *F=<some format> overrides the default format for that particular PCTN or other percent calculations.

 

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 3 replies
  • 153 views
  • 0 likes
  • 3 in conversation