<?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: Question about FORMAT in SAS News and Q&amp;A</title>
    <link>https://communities.sas.com/t5/SAS-News-and-Q-A/Question-about-FORMAT/m-p/735121#M51</link>
    <description>&lt;P&gt;The percent syntax express a given number as a percentage.&lt;/P&gt;
&lt;P&gt;In percet w.d , w means total length and d means decimal parts.&lt;/P&gt;
&lt;P&gt;w must be greater than 3. Because, '%' occupies 3 digits.&lt;/P&gt;</description>
    <pubDate>Sun, 18 Apr 2021 18:37:37 GMT</pubDate>
    <dc:creator>AmeeKang</dc:creator>
    <dc:date>2021-04-18T18:37:37Z</dc:date>
    <item>
      <title>Question about FORMAT</title>
      <link>https://communities.sas.com/t5/SAS-News-and-Q-A/Question-about-FORMAT/m-p/735008#M49</link>
      <description>&lt;P&gt;I've had a curiosity about code below. And for reference, I've used SAS university version.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA dept;
INPUT name $18. +1 hired DATE7.
+1 salary 5. +1 pct PERCENT5.1;
FORMAT hired YYMMDD10. salary DOLLAR9.1
pct PERCENT7.1;
CARDS;
Martin, Virginia   09aug98 34800 12.5%
Singleton, MaryAnn 24apr99 27900 26.3%
Leighton, Maurice  16dec15 32600 18.9%
Freuler, Carl      15feb88 29900 11.2%
Cage, Merce        19oct00 39800 23.1%
;

PROC PRINT DATA=dept;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;let us look at percent format syntax! In input sentence, PERCENT5.1 is fine in running code, but in format sentence, PERCENT length is at least 7.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried to write PERCENT5.1 in format sentence, but pct values are truncated like 13%, 26%, etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;Why are they different? I thought that It isn't problem that Input length and output(format) length are same. So, could you fix my error of thought?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Nov 2021 16:11:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-News-and-Q-A/Question-about-FORMAT/m-p/735008#M49</guid>
      <dc:creator>Minho_Kang</dc:creator>
      <dc:date>2021-11-09T16:11:07Z</dc:date>
    </item>
    <item>
      <title>Re: Question about FORMAT</title>
      <link>https://communities.sas.com/t5/SAS-News-and-Q-A/Question-about-FORMAT/m-p/735012#M50</link>
      <description>&lt;P&gt;I like your question and it made me consult the documentation. What I found &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/ds2ref/n1sw88r281qsn1n1r77pj0zn40ha.htm" target="_self"&gt;here&lt;/A&gt; for &lt;STRONG&gt;format&lt;/STRONG&gt;&amp;nbsp;&lt;SPAN&gt;PERCENT&lt;/SPAN&gt;&lt;EM class="xisDoc-userSuppliedValue"&gt;w&lt;/EM&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;EM class="xisDoc-userSuppliedValue"&gt;d&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1618715531048.png" style="width: 775px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/58239i041ABDEA1025B45C/image-dimensions/775x64?v=v2" width="775" height="64" role="button" title="Patrick_0-1618715531048.png" alt="Patrick_0-1618715531048.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;It appears the length you need to define as &lt;STRONG&gt;&lt;EM&gt;w&lt;/EM&gt;&lt;/STRONG&gt; must also leave space for two potential parentheses.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code you've posted also touches on something else that's important to know.&lt;/P&gt;
&lt;P&gt;The first&amp;nbsp;&lt;SPAN&gt;PERCENT&lt;/SPAN&gt;&lt;EM class="xisDoc-userSuppliedValue"&gt;w&lt;/EM&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;EM class="xisDoc-userSuppliedValue"&gt;d&amp;nbsp;&lt;/EM&gt;you're using is a&lt;STRONG&gt;&amp;nbsp;informat&lt;/STRONG&gt; documented &lt;A href="https://documentation.sas.com/doc/en/vdmmlcdc/8.1/leforinforref/n04gd7u98i0arzn17562whq5tow2.htm" target="_self"&gt;here&lt;/A&gt;. What you find there is:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_1-1618716046359.png" style="width: 648px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/58240iBAE48097A61FDA76/image-dimensions/648x34?v=v2" width="648" height="34" role="button" title="Patrick_1-1618716046359.png" alt="Patrick_1-1618716046359.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Above is something that applies for all numerical informats and it's something that's not very intuitive to me - and I've also seen other people stepping into this "trap".&lt;/P&gt;
&lt;P&gt;What above statement actually means: If you define a value for &lt;EM&gt;d&lt;/EM&gt; but your source string does not contain a dot with a decimal portion then SAS will divide the source value by 10 power &lt;EM&gt;d&lt;/EM&gt; when reading it into SAS. That's something you very rarely want to happen.&lt;/P&gt;
&lt;P&gt;As a rule of thumb: Never define a &lt;STRONG&gt;&lt;EM&gt;d&lt;/EM&gt;&lt;/STRONG&gt; value in an informat unless you have a very good reason to do so. For your code just use:&lt;/P&gt;
&lt;PRE&gt;input ... pct PERCENT5.&lt;/PRE&gt;
&lt;P&gt;To illustrate the behavior when defining a &lt;STRONG&gt;&lt;EM&gt;d&lt;/EM&gt;&lt;/STRONG&gt; value check-out what happens to the pct value in the last row.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA dept;
  INPUT name $18. +1 hired DATE7.
    +1 salary 5. +1 pct PERCENT5.1;
  FORMAT hired YYMMDD10. salary DOLLAR9.1
    pct PERCENT7.1;
  CARDS;
Martin, Virginia   09aug98 34800 12.5%
Singleton, MaryAnn 24apr99 27900 26.3%
Leighton, Maurice  16dec15 32600 18.9%
Freuler, Carl      15feb88 29900 11.2%
Cage, Merce        19oct00 39800 23.1%
Cage, Merce        19oct00 39800 23%
;

PROC PRINT DATA=dept;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_2-1618716454769.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/58241i810E63F300DCB9BB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_2-1618716454769.png" alt="Patrick_2-1618716454769.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;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Apr 2021 06:20:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-News-and-Q-A/Question-about-FORMAT/m-p/735012#M50</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-04-19T06:20:58Z</dc:date>
    </item>
    <item>
      <title>Re: Question about FORMAT</title>
      <link>https://communities.sas.com/t5/SAS-News-and-Q-A/Question-about-FORMAT/m-p/735121#M51</link>
      <description>&lt;P&gt;The percent syntax express a given number as a percentage.&lt;/P&gt;
&lt;P&gt;In percet w.d , w means total length and d means decimal parts.&lt;/P&gt;
&lt;P&gt;w must be greater than 3. Because, '%' occupies 3 digits.&lt;/P&gt;</description>
      <pubDate>Sun, 18 Apr 2021 18:37:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-News-and-Q-A/Question-about-FORMAT/m-p/735121#M51</guid>
      <dc:creator>AmeeKang</dc:creator>
      <dc:date>2021-04-18T18:37:37Z</dc:date>
    </item>
    <item>
      <title>Re: Question about FORMAT</title>
      <link>https://communities.sas.com/t5/SAS-News-and-Q-A/Question-about-FORMAT/m-p/735135#M52</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/335270"&gt;@AmeeKang&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;The percent syntax express a given number as a percentage.&lt;/P&gt;
&lt;P&gt;In percet w.d , w means total length and d means decimal parts.&lt;/P&gt;
&lt;P&gt;w must be greater than 3. Because, '%' occupies 3 digits.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;More because "(%)" occupies 3 digits. The Percent format to display negative values uses () around the value, so you need to accommodate those even if there are no negative values in your data. (1.2%) is how the format displays -1.2%&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Apr 2021 22:26:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-News-and-Q-A/Question-about-FORMAT/m-p/735135#M52</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-04-18T22:26:55Z</dc:date>
    </item>
  </channel>
</rss>

