<?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: Convert character to numeric in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Convert-character-to-numeric/m-p/462279#M117673</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Price $;
datalines;
104
104.25
104.35
103
;

data want;
    set have;
    NumPrice=input(Price, 8.);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 15 May 2018 07:13:55 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2018-05-15T07:13:55Z</dc:date>
    <item>
      <title>Convert character to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-character-to-numeric/m-p/462267#M117665</link>
      <description>&lt;P&gt;Hello, I&amp;nbsp; want to convert character to numeric.&lt;/P&gt;&lt;P&gt;My data looks like this :&lt;/P&gt;&lt;P&gt;104&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;104.25&lt;/P&gt;&lt;P&gt;104.35&lt;/P&gt;&lt;P&gt;103&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried to use input&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;Price_new = input(Price, &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;best12.2&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;But the result I get as follows:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;104&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1.04&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;104.25&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 104.25&lt;/P&gt;&lt;P&gt;104.35&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 104.3&lt;/P&gt;&lt;P&gt;103&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1.03&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As you can see the problem is when the number is without decimal point. Please help me.&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Tue, 15 May 2018 06:35:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-character-to-numeric/m-p/462267#M117665</guid>
      <dc:creator>AlexeyS</dc:creator>
      <dc:date>2018-05-15T06:35:38Z</dc:date>
    </item>
    <item>
      <title>Re: Convert character to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-character-to-numeric/m-p/462279#M117673</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Price $;
datalines;
104
104.25
104.35
103
;

data want;
    set have;
    NumPrice=input(Price, 8.);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 15 May 2018 07:13:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-character-to-numeric/m-p/462279#M117673</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-05-15T07:13:55Z</dc:date>
    </item>
    <item>
      <title>Re: Convert character to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-character-to-numeric/m-p/462298#M117684</link>
      <description>&lt;P&gt;When you specify decimals in an informat (as in your input function), you &lt;EM&gt;force&lt;/EM&gt; SAS to convert as many digits to decimals when no decimal point is found in the string. You only specify decimals in an informat when you need to do that conversion yourself (eg when you receive decimal fixed data from mainframes).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edited because decimal point in instring overrides format definition.&lt;/P&gt;</description>
      <pubDate>Tue, 15 May 2018 12:28:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-character-to-numeric/m-p/462298#M117684</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-05-15T12:28:35Z</dc:date>
    </item>
    <item>
      <title>Re: Convert character to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-character-to-numeric/m-p/462319#M117693</link>
      <description>&lt;P&gt;SAS is just doing what you asked it to do.&amp;nbsp; The decimal part of an INFORMAT tells SAS where to place the decimal point when the text string doesn't have one.&amp;nbsp; It is for reading data that has been written without the decimal point on purpose to save space in the text file.&lt;/P&gt;
&lt;P&gt;Just use an informat of 32.. Or even better use COMMA32. as it will handle strings that include commas and dollar signs.&lt;/P&gt;</description>
      <pubDate>Tue, 15 May 2018 12:22:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-character-to-numeric/m-p/462319#M117693</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-05-15T12:22:52Z</dc:date>
    </item>
    <item>
      <title>Re: Convert character to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-character-to-numeric/m-p/462338#M117702</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Try&lt;/P&gt;&lt;P&gt;data ds;&lt;BR /&gt;infile datalines;&lt;BR /&gt;input proce_new$;&lt;BR /&gt;new_price=input(proce_new,12.);&lt;BR /&gt;datalines;&lt;BR /&gt;104&lt;BR /&gt;104.25&lt;BR /&gt;104.35&lt;BR /&gt;103&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Srinath&lt;/P&gt;</description>
      <pubDate>Tue, 15 May 2018 13:02:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-character-to-numeric/m-p/462338#M117702</guid>
      <dc:creator>srinath3111</dc:creator>
      <dc:date>2018-05-15T13:02:58Z</dc:date>
    </item>
  </channel>
</rss>

