turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- General Programming
- /
- Formatting a decimal as a percent

Topic Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

10-20-2014 02:19 PM

Hello everyone,

I have three variables A, B and C coded as 0/1 and I am using proc tabulate to create the following table:

N | % | |
---|---|---|

A | 22857 | 33% |

B | 16088 | 23% |

C | 56576 | 81% |

proc tabulate data=test;

var A B C;

TABLE A B C, (SUM="N"*F=8.0 MEAN="%"*F=PERCENT8.0);

RUN;

The percentage is actually calculated as the mean but formatted as a percent.

Is there any way that I can format the decimal of 0.81 to show as 81 rather than as 81% in this particular example?

Many thanks!

Sarasvati

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to saras

10-20-2014 02:43 PM

I have managed to find a solution. There didn't seem to be a preexisting format that I could use. But I was able to use a picture format and specify a multiplier 10^2 to convert the decimal to percent. I was also able to included brackets around the percentages in this way.

proc format;

picture mypct low-high='009)'

(prefix='(' mult=100);

run;

proc tabulate data=test;

var A B C;

TABLE A B C, (SUM="N"*F=8.0 MEAN="%"*F=mypct);

RUN;

Base SAS(R) 9.2 Procedures Guide

Sarasvati