<?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: Why is the numeric value getting converted to character while using input statement? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Why-is-the-numeric-value-getting-converted-to-character-while/m-p/696339#M212670</link>
    <description>&lt;P&gt;The input function requires a character value. So when you feed it a numeric value it converts it into a character value, usually using some form of BEST format. Then "inputs" the result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The question is why would you even attempt an input of such a thing? What do you expect to result?&lt;/P&gt;
&lt;P&gt;Generally the approach would be to do a numeric calculation and round the result if you don't want more than one decimal.&lt;/P&gt;
&lt;P&gt;Perhaps&lt;/P&gt;
&lt;P&gt;max = round( n1/n2, 0.1);&lt;/P&gt;
&lt;P&gt;Or show us the explicit result you are expecting/wanting.&lt;/P&gt;</description>
    <pubDate>Tue, 03 Nov 2020 21:50:01 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2020-11-03T21:50:01Z</dc:date>
    <item>
      <title>Why is the numeric value getting converted to character while using input statement?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-is-the-numeric-value-getting-converted-to-character-while/m-p/696331#M212667</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;Below is the program. When I apply format to max it works perfectly as expected, but I was trying to use input statement and the results did not look right at all. One of my colleagues also suggested I can re-write it as&amp;nbsp;max1= input(put((n1/n2),4.1),best.); but I still did not understand why input is converting numeric values to character in the first place. Any help?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data dryrun;&lt;BR /&gt;&amp;nbsp; input n1 n2;&lt;BR /&gt;&amp;nbsp; max = n1/n2;&lt;BR /&gt;&amp;nbsp; max1= input((n1/n2),4.1);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;format max 4.1;&lt;BR /&gt;datalines;&lt;BR /&gt;37 53&lt;BR /&gt;40 52&lt;BR /&gt;39 52&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Nov 2020 21:30:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-is-the-numeric-value-getting-converted-to-character-while/m-p/696331#M212667</guid>
      <dc:creator>Tommer</dc:creator>
      <dc:date>2020-11-03T21:30:21Z</dc:date>
    </item>
    <item>
      <title>Re: Why is the numeric value getting converted to character while using input statement?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-is-the-numeric-value-getting-converted-to-character-while/m-p/696339#M212670</link>
      <description>&lt;P&gt;The input function requires a character value. So when you feed it a numeric value it converts it into a character value, usually using some form of BEST format. Then "inputs" the result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The question is why would you even attempt an input of such a thing? What do you expect to result?&lt;/P&gt;
&lt;P&gt;Generally the approach would be to do a numeric calculation and round the result if you don't want more than one decimal.&lt;/P&gt;
&lt;P&gt;Perhaps&lt;/P&gt;
&lt;P&gt;max = round( n1/n2, 0.1);&lt;/P&gt;
&lt;P&gt;Or show us the explicit result you are expecting/wanting.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Nov 2020 21:50:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-is-the-numeric-value-getting-converted-to-character-while/m-p/696339#M212670</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-11-03T21:50:01Z</dc:date>
    </item>
    <item>
      <title>Re: Why is the numeric value getting converted to character while using input statement?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-is-the-numeric-value-getting-converted-to-character-while/m-p/696382#M212691</link>
      <description>thanks &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt; I was fixing a lengthy existing program where I came across using input function throughout the program in this way and noticed the conversion and that the values did not look right. I am assuming it was used to display it in 4.1 format using input function and numeric to numeric conversion. But I was not clear as why it did not work. Now, I get it. It was looking for a character value and thus, the automatic conversion occurred.</description>
      <pubDate>Wed, 04 Nov 2020 00:14:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-is-the-numeric-value-getting-converted-to-character-while/m-p/696382#M212691</guid>
      <dc:creator>Tommer</dc:creator>
      <dc:date>2020-11-04T00:14:11Z</dc:date>
    </item>
  </channel>
</rss>

