Formatting a decimal as a percent

Reply
Occasional Contributor
Posts: 8

Formatting a decimal as a percent

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%
A22857  33%
B16088  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

Occasional Contributor
Posts: 8

Re: Formatting a decimal as a percent

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

Ask a Question
Discussion stats
  • 1 reply
  • 243 views
  • 0 likes
  • 1 in conversation