04-17-2015 08:57 AM
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?
04-17-2015 09:16 AM
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.
04-17-2015 09:29 AM
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.
format a percent9.4;
format b percent10.4;
format c percent11.4;
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_;
27 format a percent9.4;
28 put a=;
29 format b percent10.4;
30 put b=;
31 format c percent11.4;
32 put c=;
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'.
04-17-2015 10:00 AM
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."