<?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: How does SAS input an integer by format like x.y in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-does-SAS-input-an-integer-by-format-like-x-y/m-p/686594#M208386</link>
    <description>&lt;P&gt;When you use informat&amp;nbsp;&lt;SPAN&gt;4.2&lt;/SPAN&gt;&amp;nbsp;you tell SAS that you want 2 decimals.&lt;/P&gt;
&lt;P&gt;If SAS finds a decimal dot, it uses it. If not, it considers the last 2 digits to be the 2 decimal values.&lt;/P&gt;</description>
    <pubDate>Fri, 25 Sep 2020 02:30:08 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2020-09-25T02:30:08Z</dc:date>
    <item>
      <title>How does SAS input an integer by format like x.y</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-does-SAS-input-an-integer-by-format-like-x-y/m-p/686586#M208380</link>
      <description>&lt;P&gt;&lt;SPAN&gt;My friend asked me a question:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  test = input(12,4.2);
  put test = ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;The result is 0.12, why?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I do some test on this and I guess&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;SAS read the string '12' from right to left to determin the position of decimal point&lt;/STRONG&gt;. When I test&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;test = input(123,4.2);&lt;/CODE&gt;, it gives me&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;1.23&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;which support my assumption. But when I test&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;test = input(12.0,4.2);&lt;/CODE&gt;, it returns&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;12&lt;/CODE&gt;. So I do more test on this and have another guess:&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;SAS have different policy on inputing decimal and integer&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Am I right? Or you have other idea?&lt;/P&gt;</description>
      <pubDate>Fri, 25 Sep 2020 01:16:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-does-SAS-input-an-integer-by-format-like-x-y/m-p/686586#M208380</guid>
      <dc:creator>whymath</dc:creator>
      <dc:date>2020-09-25T01:16:43Z</dc:date>
    </item>
    <item>
      <title>Re: How does SAS input an integer by format like x.y</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-does-SAS-input-an-integer-by-format-like-x-y/m-p/686594#M208386</link>
      <description>&lt;P&gt;When you use informat&amp;nbsp;&lt;SPAN&gt;4.2&lt;/SPAN&gt;&amp;nbsp;you tell SAS that you want 2 decimals.&lt;/P&gt;
&lt;P&gt;If SAS finds a decimal dot, it uses it. If not, it considers the last 2 digits to be the 2 decimal values.&lt;/P&gt;</description>
      <pubDate>Fri, 25 Sep 2020 02:30:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-does-SAS-input-an-integer-by-format-like-x-y/m-p/686594#M208386</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-09-25T02:30:08Z</dc:date>
    </item>
    <item>
      <title>Re: How does SAS input an integer by format like x.y</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-does-SAS-input-an-integer-by-format-like-x-y/m-p/686616#M208401</link>
      <description>&lt;P&gt;Yes, someone gives me the solution.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;STRONG&gt;w.d Informat&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Reads standard numeric data.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;...&lt;/SPAN&gt;&lt;BR /&gt;&lt;STRONG&gt;Syntax&lt;/STRONG&gt;&lt;BR /&gt;&lt;EM&gt;w.d&lt;/EM&gt;&lt;BR /&gt;&lt;STRONG&gt;Syntax Description&lt;/STRONG&gt;&lt;BR /&gt;&lt;EM&gt;&lt;STRONG&gt;w&lt;/STRONG&gt;&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;specifies the width of the input field. Range 1–32&lt;/SPAN&gt;&lt;BR /&gt;&lt;EM&gt;&lt;STRONG&gt;d&lt;/STRONG&gt;&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;specifies the power of 10 by which to divide the value.&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;If the data contains decimal points, the&lt;EM&gt;d&lt;/EM&gt;value is ignored&lt;/STRONG&gt;&lt;SPAN&gt;. This argument is optional. Range 0–31&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;And here is the link:&amp;nbsp;&lt;A href="https://documentation.sas.com/?docsetId=leforinforref&amp;amp;docsetTarget=n14sqpf1cubqknn1vmkzkp1oph87.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank"&gt;https://documentation.sas.com/?docsetId=leforinforref&amp;amp;docsetTarget=n14sqpf1cubqknn1vmkzkp1oph87.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Sep 2020 06:22:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-does-SAS-input-an-integer-by-format-like-x-y/m-p/686616#M208401</guid>
      <dc:creator>whymath</dc:creator>
      <dc:date>2020-09-25T06:22:18Z</dc:date>
    </item>
    <item>
      <title>Re: How does SAS input an integer by format like x.y</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-does-SAS-input-an-integer-by-format-like-x-y/m-p/686728#M208437</link>
      <description>&lt;P&gt;Some ancient history may shed some light on this.&lt;/P&gt;
&lt;P&gt;Once upon a time there were things called punchcards, actual physical cards that holes were punched in specific that early computers could read data. These were used for many things that had to share information between computers that were not connected and often incompatible. The cards and coding schemes were create long before computers so they became a standard of sharing data.&lt;/P&gt;
&lt;P&gt;These cards only held 80 columns or positions. So to reduce how much had to be physically punched on the cards rules for reading would imply that a specific column was an implied decimal. So only 1234 had to be punched but the using program "knew" that there should be a decimal between the 2 and 3 and treat the value as 12.34. &lt;BR /&gt;The cards could often hold more values when there was no actual decimal. You might have a card that held something like:&lt;/P&gt;
&lt;P&gt;1234599976323448504827634950560679583772722495506679&lt;/P&gt;
&lt;P&gt;but a computer could read that as&lt;/P&gt;
&lt;P&gt;12.34&amp;nbsp;&amp;nbsp; 599.976&amp;nbsp;&amp;nbsp;&amp;nbsp; .323448 504.82&amp;nbsp;&amp;nbsp;&amp;nbsp; 76.3495 0.5606&amp;nbsp; 7958.37&amp;nbsp; 727.22&amp;nbsp;&amp;nbsp; 4955.06679&lt;/P&gt;
&lt;P&gt;So the W.D and other formats when a decimal is used have this old behavior. It continued for things like text based files because transmission speeds or file sizes presented some challenges for a long time and the space saving was still useful. Or the old program still worked and the "if it ain't broke don't fix it" rule applied.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So the input function and input statement behavior maintains consistency with old behavior. Moral of the story: don't read integers with a decimal informat&amp;nbsp; (other than 0 such as 5.0).&lt;/P&gt;</description>
      <pubDate>Fri, 25 Sep 2020 15:13:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-does-SAS-input-an-integer-by-format-like-x-y/m-p/686728#M208437</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-09-25T15:13:14Z</dc:date>
    </item>
  </channel>
</rss>

