Help using Base SAS procedures

Convert Decimal to Percent %

Reply
Contributor
Posts: 73

Convert Decimal to Percent %

How can i convert this decimal outcome to show percent %


proc sql;
create table test as
select _NAME_,
case
when (Y__Service_Level)=(BR_PercentServiceLevel)then 0
else Y__Service_Level - BR_PercentServiceLevel
end as PercentServiceLevel
from cscore.BRSmerge;
quit;
Valued Guide
Posts: 634

Re: Convert Decimal to Percent %

Have you tried using the PERCENT format?
N/A
Posts: 0

Re: Convert Decimal to Percent %

use the format percent12.2 or percent15.

ex:
proc sql;
create table a as select * a/b as c format percent12.2 from ;
quit;
Contributor
Posts: 73

Re: Convert Decimal to Percent %

Posted in reply to deleted_user
Thanks user4sas this was helpful, thanks for the example.

Fred
Contributor
Posts: 73

Re: Convert Decimal to Percent %

Posted in reply to deleted_user
Hello again

I'm looking for some doc. to help explain how the format percent12.2 works

How do i figure out to apply 12.2 or 8.1 or what?

If you can lead me to some information that would be great, i've looked online but can't find anything.

Thanks again.

Fred
PROC Star
Posts: 7,467

Re: Convert Decimal to Percent %

Fred,

The documentation can be found at: http://support.sas.com/documentation/cdl/en/lrdict/63026/HTML/default/viewer.htm#a000205182.htm

or, if that wraps, in short form: http://xrl.us/bhznnr

In short, the first number indicates the width you want (including after the decimal), while the second number indicates the number of decimal places wanted.

HTH,
Art
SAS Super FREQ
Posts: 8,862

Re: Convert Decimal to Percent %

And, if you are using the PERCENT format, be sure to make the overall width "wide" enough -- usually 8.1 works for me if I have 1 decimal place:
From the Doc:
Tip: The width of the output field must account for the percent sign (% ) and parentheses for negative numbers, whether the number is negative or positive.


cynthia
Contributor
Posts: 73

Re: Convert Decimal to Percent %

Posted in reply to Cynthia_sas
Thanks everyone
Ask a Question
Discussion stats
  • 7 replies
  • 6684 views
  • 0 likes
  • 5 in conversation