<?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 Percentn-format in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Percentn-format/m-p/660825#M197694</link>
    <description>&lt;P&gt;Hi all&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The percentn-format is a tricky one for me to understand.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Percentn10.2 where 10 is called the first parameter and 2 is called the second&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have experienced just to use a fairly wide first parameter and then specify the last parameter according to my need.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But why is that?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I do the following:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test2;
length format $50.;
length var $50.;
format='percentn4.0'; var=put(0.10412456435, percentn4.0); output;
format='percentn4.1'; var=put(0.10412456435, percentn4.1); output;
format='percentn4.2'; var=put(0.10412456435, percentn4.2); output;
format='percentn4.3'; var=put(0.10412456435, percentn4.3); output;
format='percentn5.0'; var=put(0.10412456435, percentn5.0); output;
format='percentn5.1'; var=put(0.10412456435, percentn5.1); output;
format='percentn5.2'; var=put(0.10412456435, percentn5.2); output;
format='percentn5.3'; var=put(0.10412456435, percentn5.3); output;
format='percentn5.4'; var=put(0.10412456435, percentn5.4); output;
format='percentn6.0'; var=put(0.10412456435, percentn6.0); output;
format='percentn6.1'; var=put(0.10412456435, percentn6.1); output;
format='percentn6.2'; var=put(0.10412456435, percentn6.2); output;
format='percentn6.3'; var=put(0.10412456435, percentn6.3); output;
format='percentn6.4'; var=put(0.10412456435, percentn6.4); output;
format='percentn6.5'; var=put(0.10412456435, percentn6.5); output;
format='percentn7.0'; var=put(0.10412456435, percentn7.0); output;
format='percentn7.1'; var=put(0.10412456435, percentn7.1); output;
format='percentn7.2'; var=put(0.10412456435, percentn7.2); output;
format='percentn7.3'; var=put(0.10412456435, percentn7.3); output;
format='percentn7.4'; var=put(0.10412456435, percentn7.4); output;
format='percentn7.5'; var=put(0.10412456435, percentn7.5); output;
format='percentn7.6'; var=put(0.10412456435, percentn7.6); output;
format='percentn8.0'; var=put(0.10412456435, percentn8.0); output;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why is percent4.0 not giving me 10% instead of *%.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I guess the dot (.) and % are included in the first parameter. But still.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The way I have come to live with it is by assuming the % consist of two dots and a slash. Then it makes sense. But I cannot be what is going on.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can anyone help a troubled soul?&lt;/P&gt;</description>
    <pubDate>Wed, 17 Jun 2020 05:36:37 GMT</pubDate>
    <dc:creator>SanderEhmsen</dc:creator>
    <dc:date>2020-06-17T05:36:37Z</dc:date>
    <item>
      <title>Percentn-format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Percentn-format/m-p/660825#M197694</link>
      <description>&lt;P&gt;Hi all&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The percentn-format is a tricky one for me to understand.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Percentn10.2 where 10 is called the first parameter and 2 is called the second&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have experienced just to use a fairly wide first parameter and then specify the last parameter according to my need.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But why is that?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I do the following:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test2;
length format $50.;
length var $50.;
format='percentn4.0'; var=put(0.10412456435, percentn4.0); output;
format='percentn4.1'; var=put(0.10412456435, percentn4.1); output;
format='percentn4.2'; var=put(0.10412456435, percentn4.2); output;
format='percentn4.3'; var=put(0.10412456435, percentn4.3); output;
format='percentn5.0'; var=put(0.10412456435, percentn5.0); output;
format='percentn5.1'; var=put(0.10412456435, percentn5.1); output;
format='percentn5.2'; var=put(0.10412456435, percentn5.2); output;
format='percentn5.3'; var=put(0.10412456435, percentn5.3); output;
format='percentn5.4'; var=put(0.10412456435, percentn5.4); output;
format='percentn6.0'; var=put(0.10412456435, percentn6.0); output;
format='percentn6.1'; var=put(0.10412456435, percentn6.1); output;
format='percentn6.2'; var=put(0.10412456435, percentn6.2); output;
format='percentn6.3'; var=put(0.10412456435, percentn6.3); output;
format='percentn6.4'; var=put(0.10412456435, percentn6.4); output;
format='percentn6.5'; var=put(0.10412456435, percentn6.5); output;
format='percentn7.0'; var=put(0.10412456435, percentn7.0); output;
format='percentn7.1'; var=put(0.10412456435, percentn7.1); output;
format='percentn7.2'; var=put(0.10412456435, percentn7.2); output;
format='percentn7.3'; var=put(0.10412456435, percentn7.3); output;
format='percentn7.4'; var=put(0.10412456435, percentn7.4); output;
format='percentn7.5'; var=put(0.10412456435, percentn7.5); output;
format='percentn7.6'; var=put(0.10412456435, percentn7.6); output;
format='percentn8.0'; var=put(0.10412456435, percentn8.0); output;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why is percent4.0 not giving me 10% instead of *%.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I guess the dot (.) and % are included in the first parameter. But still.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The way I have come to live with it is by assuming the % consist of two dots and a slash. Then it makes sense. But I cannot be what is going on.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can anyone help a troubled soul?&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jun 2020 05:36:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Percentn-format/m-p/660825#M197694</guid>
      <dc:creator>SanderEhmsen</dc:creator>
      <dc:date>2020-06-17T05:36:37Z</dc:date>
    </item>
    <item>
      <title>Re: Percentn-format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Percentn-format/m-p/660950#M197696</link>
      <description>&lt;P&gt;Your code shows use of PerctNw.d format but your question asks about Percentw.d. They are not the same in behavior.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The Percentw.d uses parentheses around values to indicate negative values. So two of the 4 positions are reserved for those when they might appear which leaves only 2 of 4 to display the value. One more position gets taken by the % sign. So there is only one character position for the numeric value. Which means it can only display 1 digit and since 10% can not be displayed with 1 digit you get the *, which is generally SAS's way of telling you that your format is not wide enough to display.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The case is similar when you use PercentNw.d. The PercentN will show negative values with a minus sign preceding, so the format needs one character for that plus one for the % and a trailing blank.(never really got why, but that's in the documentation) So again leaves only one space for the value and 10 won't fit in the remaining 1 character with percentn4.&lt;/P&gt;
&lt;P&gt;When you start specifying decimal more characters are reserved for them and you can run of digits quickly. Any format with a width of 4 and 3 decimal places won't show any integer portion because you asked for 3 decimal positions &lt;STRONG&gt;plus&lt;/STRONG&gt; a decimal point. And that's before you get into the minus sign the format will reserve without showing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your log shows a note like this because of attempting to fit values into to little space.&lt;/P&gt;
&lt;PRE&gt;NOTE: At least one W.D format was too small for the number to be printed. The decimal may be
      shifted by the "BEST" format.
&lt;/PRE&gt;
&lt;P&gt;The order of when which spaces get reserved for which part of the rule seem to be a bit odd when the percent and percentn formats are used. So if I want to show 2 decimals I start with Percent8.2 but that will have issues if the value is 10 or greater (1000%)&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jun 2020 08:23:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Percentn-format/m-p/660950#M197696</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-06-17T08:23:54Z</dc:date>
    </item>
  </channel>
</rss>

