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

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 3 replies
  • 275 views
  • 0 likes
  • 3 in conversation