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;
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.
From the PROC TABULATE documentation, you just need to add a format.
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 |
|
In your case, you want the PERCENTw.d format
@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.
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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.