Percent format question

Posts: 69

Percent format question

I am using a percent7.4 format for a calculation and specifically looking for any percentage greater than 101%.  The problem is any percentage greater than 100 is not showing any decimal places.  My users are questioning the value as the requements state GT 101%, but I am not able to show the decimal places that prove the percentage is actually greater than 101%.  How do I solve for that?  that is part one, that piece is on mainframe. 

I then move the data file to a unix server where I have a program that pulls in the data and uses ods to create a report in excel.  I currently am reading in that percentage as character 6., and outputting  as tagattr='format:##00.0%'.  Is that tagattr correct for the output I am looking for?



Super User
Posts: 6,928

Re: Percent format question

Keep in mind that with a percent7.4 format, you run out of space quickly. SAS obviously needs space for more characters than are displayed.

To display % values <= 1 with 4 decimals, use percent11.4.

Maxims of Maximally Efficient SAS Programmers
Respected Advisor
Posts: 3,124

Re: Percent format question

This one bothers me as well. In SAS Doc, Percentw.d, w is the total width of the output, d is the digits after decimal point.

So if we have 1.234567, the width should be 7+1(decimal point)+1(%) =9, therefore Percent9.4 should be sufficient to show:  123.4567%. However, we will need Percent11.4 to show the whole number without rounding.

data _null_;




     format a percent9.4;

     put a=;

     format b percent10.4;

     put b=;

     format c percent11.4;

     put c=;


Log shows:




The reason, my guess, is that this format needs to reserver 2 digits for negative number, which takes length of 2 by denoting as (). see below:

23 data _null_;

24 a=-1.234567;

25 b=a;

26 c=a;

27 format a percent9.4;

28 put a=;

29 format b percent10.4;

30 put b=;

31 format c percent11.4;

32 put c=;

33 run;




Therefore for your problem, first multiply the number by 100, then decide the digits after the decimal point you want to keep as 'd', then use the formula above and plus 2  as 'w'.


Valued Guide
Posts: 3,208

Re: Percent format question

SAS(R) 9.4 Formats and Informats: Reference   "The width of the output field must account for the percent sign (% ) and parentheses for negative numbers, whether the number is negative or positive."

---->-- ja karman --<-----
Respected Advisor
Posts: 3,124

Re: Percent format question

Thanks, Jaap! I must have been blind Smiley Happy.

Ask a Question
Discussion stats
  • 4 replies
  • 4 in conversation