<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: percent format in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/percent-format/m-p/968414#M376562</link>
    <description>&lt;P&gt;Count the characters and set the WIDTH of the format to match.&lt;/P&gt;
&lt;P&gt;Also count the number of digits you want after the decimal point and set the DECIMAL places part of the format to match.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Notice that when you set too short of a WIDTH then SAS will move the decimal point to make the actual value fit into the space allocated.&amp;nbsp; &amp;nbsp;That is why you don't get the leading zero in your example.&amp;nbsp; And also why it does not show you the 5th decimal place you asked for.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To show 5 decimal digits with percentages between 0 and 100 you will need 12 characters.&lt;/P&gt;
&lt;P&gt;If you only want 4 decimal digits then use 4 instead of 5 and then you can reduce the width from 12 to 11.&lt;/P&gt;
&lt;PRE&gt;(0.0574%)
123456789
   1234

(100.00000%)
123456789012
     12345
&lt;/PRE&gt;
&lt;P&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 09 Jun 2025 02:51:55 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2025-06-09T02:51:55Z</dc:date>
    <item>
      <title>percent format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/percent-format/m-p/968402#M376557</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I want to ask about percent format.&lt;/P&gt;
&lt;P&gt;The format&amp;nbsp; PCT1 show&amp;nbsp;.0574%&amp;nbsp; but I want it to show&amp;nbsp; 0.0574%&lt;/P&gt;
&lt;P&gt;The format PCT2 show&amp;nbsp;(.0574%)&amp;nbsp; but I want it to show&amp;nbsp;(0.0574%)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data have;
x1=1276;
x2=-1276;
total=2222151;
pct1=x1/total;
pct2=x2/total;
format pct1 pct2 percent8.5;
Run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 08 Jun 2025 19:52:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/percent-format/m-p/968402#M376557</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2025-06-08T19:52:40Z</dc:date>
    </item>
    <item>
      <title>Re: percent format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/percent-format/m-p/968405#M376558</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does using format &lt;FONT face="courier new,courier"&gt;percent9.4&lt;/FONT&gt; give you what you want, as below?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  x1 = 1276;
  x2 =-1276;
  total = 2222151;
  pct1 = x1/total;
  pct2 = x2/total;
  format pct1 pct2 percent9.4;
run;


proc print data = have;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Amir_0-1749421350230.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/107688i701DC9A8278DEA25/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Amir_0-1749421350230.png" alt="Amir_0-1749421350230.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks &amp;amp; kind regards,&lt;/P&gt;
&lt;P&gt;Amir.&lt;/P&gt;</description>
      <pubDate>Sun, 08 Jun 2025 22:22:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/percent-format/m-p/968405#M376558</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2025-06-08T22:22:48Z</dc:date>
    </item>
    <item>
      <title>Re: percent format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/percent-format/m-p/968414#M376562</link>
      <description>&lt;P&gt;Count the characters and set the WIDTH of the format to match.&lt;/P&gt;
&lt;P&gt;Also count the number of digits you want after the decimal point and set the DECIMAL places part of the format to match.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Notice that when you set too short of a WIDTH then SAS will move the decimal point to make the actual value fit into the space allocated.&amp;nbsp; &amp;nbsp;That is why you don't get the leading zero in your example.&amp;nbsp; And also why it does not show you the 5th decimal place you asked for.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To show 5 decimal digits with percentages between 0 and 100 you will need 12 characters.&lt;/P&gt;
&lt;P&gt;If you only want 4 decimal digits then use 4 instead of 5 and then you can reduce the width from 12 to 11.&lt;/P&gt;
&lt;PRE&gt;(0.0574%)
123456789
   1234

(100.00000%)
123456789012
     12345
&lt;/PRE&gt;
&lt;P&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jun 2025 02:51:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/percent-format/m-p/968414#M376562</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-06-09T02:51:55Z</dc:date>
    </item>
    <item>
      <title>Re: percent format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/percent-format/m-p/968795#M376641</link>
      <description>&lt;P&gt;Counting columns is skill and seems to be disappearing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I want to ask about percent format.&lt;/P&gt;
&lt;P&gt;The format&amp;nbsp; PCT1 show&amp;nbsp;.0574%&amp;nbsp; but I want it to show&amp;nbsp; 0.0574%&lt;/P&gt;
&lt;P&gt;The format PCT2 show&amp;nbsp;(.0574%)&amp;nbsp; but I want it to show&lt;FONT color="#800080"&gt;&amp;nbsp;(0.0574%)&lt;/FONT&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data have;
x1=1276;
x2=-1276;
total=2222151;
pct1=x1/total;
pct2=x2/total;
format pct1 pct2 percent8.5;
Run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT color="#800080"&gt;&amp;nbsp;(0.0574%)&lt;/FONT&gt;&amp;nbsp;is 9 characters. So does not fit well into any format defined to have a width of 8, i.e. the 8 in percent8.5.&lt;/P&gt;
&lt;P&gt;The Decimals of 5 the 5 in percent8.5 exceeds the number of decimals you actually want to show which is 4, 0574. The % symbol is not a decimal in the display. So using any .5 for the decimals may be problematic as to resulting appearances.&lt;/P&gt;
&lt;P&gt;Run this and see the results in the log:&lt;/P&gt;
&lt;PRE&gt; data _null_;
  x=-0.000574;
  put 'Format is percent8.5' x= percent8.5;
  put 'Format is percent9.5' x= percent9.5;
  put 'Format is percent9.4' x= percent9.4;
run;&lt;/PRE&gt;
&lt;P&gt;See what happens with percent9.5? Forcing the extra decimal which is what the .5 does means that you get either and unwanted 0 or other value from rounding your calculated value as the fifth decimal.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jun 2025 21:15:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/percent-format/m-p/968795#M376641</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2025-06-11T21:15:05Z</dc:date>
    </item>
    <item>
      <title>Re: percent format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/percent-format/m-p/968942#M376695</link>
      <description>&lt;PRE&gt;( 0 . 0 5 7 4 % )
1 2 3 4 5 6 7 8 9&lt;/PRE&gt;
&lt;P&gt;Just count, and use the proper number for the fractional digits.&lt;/P&gt;
&lt;P&gt;Which tells you the format should be PERCENT9.4&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jun 2025 21:13:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/percent-format/m-p/968942#M376695</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2025-06-12T21:13:02Z</dc:date>
    </item>
  </channel>
</rss>

