<?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 to convert a string with potential to numeric in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-convert-a-string-with-potential-to-numeric/m-p/387221#M92818</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Give the appropriate informat in the input statement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
format value 12.4;
input value e12.5;
datalines;
0.4567
2.678E-2
3.5679E-3
-0.1987
0.03489
0.5634
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Suryakiran&lt;/P&gt;</description>
    <pubDate>Fri, 11 Aug 2017 02:40:00 GMT</pubDate>
    <dc:creator>SuryaKiran</dc:creator>
    <dc:date>2017-08-11T02:40:00Z</dc:date>
    <item>
      <title>how to convert a string with potential to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-convert-a-string-with-potential-to-numeric/m-p/387179#M92806</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have strings need to convert to numeric.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data test;&lt;/P&gt;&lt;P&gt;input value $12.;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;0.4567&lt;/P&gt;&lt;P&gt;2.678E-2&lt;/P&gt;&lt;P&gt;3.5679E-3&lt;/P&gt;&lt;P&gt;-0.1987&lt;/P&gt;&lt;P&gt;0.03489&lt;/P&gt;&lt;P&gt;0.5634&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;how to get the numeric values. Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Aug 2017 20:14:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-convert-a-string-with-potential-to-numeric/m-p/387179#M92806</guid>
      <dc:creator>daisy6</dc:creator>
      <dc:date>2017-08-10T20:14:02Z</dc:date>
    </item>
    <item>
      <title>Re: how to convert a string with potential to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-convert-a-string-with-potential-to-numeric/m-p/387185#M92808</link>
      <description>&lt;P&gt;If you remove the $12. SAS reads in the values as numerics accurately.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you need to convert it, use INPUT with a best format, but it's more efficient to just delete the $12 in my opinion.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input value $12.;
value_num =input(value, best12.);
datalines;
0.4567
2.678E-2
3.5679E-3
-0.1987
0.03489
0.5634
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 10 Aug 2017 20:33:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-convert-a-string-with-potential-to-numeric/m-p/387185#M92808</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-08-10T20:33:12Z</dc:date>
    </item>
    <item>
      <title>Re: how to convert a string with potential to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-convert-a-string-with-potential-to-numeric/m-p/387193#M92811</link>
      <description>&lt;P&gt;If you have a data set and want to add a numeric variable:&lt;/P&gt;
&lt;PRE&gt;data work.want;
   set test;
   value_num = input(value,best.);
run;&lt;/PRE&gt;
&lt;P&gt;If you want to keep the same name for the variable you need a bit more as you cannot change the type of a variable once it is set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data work.want;
   set test (rename= (value=oldvalue) );
   value = input(oldvalue,best.);
   drop oldvalue;
run;&lt;/PRE&gt;</description>
      <pubDate>Thu, 10 Aug 2017 23:02:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-convert-a-string-with-potential-to-numeric/m-p/387193#M92811</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-08-10T23:02:14Z</dc:date>
    </item>
    <item>
      <title>Re: how to convert a string with potential to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-convert-a-string-with-potential-to-numeric/m-p/387221#M92818</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Give the appropriate informat in the input statement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
format value 12.4;
input value e12.5;
datalines;
0.4567
2.678E-2
3.5679E-3
-0.1987
0.03489
0.5634
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Suryakiran&lt;/P&gt;</description>
      <pubDate>Fri, 11 Aug 2017 02:40:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-convert-a-string-with-potential-to-numeric/m-p/387221#M92818</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2017-08-11T02:40:00Z</dc:date>
    </item>
    <item>
      <title>Re: how to convert a string with potential to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-convert-a-string-with-potential-to-numeric/m-p/387223#M92819</link>
      <description>&lt;P&gt;You can use the INPUT() function to convert a string to a number. The normal numeric informat will work with those strings.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;num_value = input(value,12.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Aug 2017 02:55:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-convert-a-string-with-potential-to-numeric/m-p/387223#M92819</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-08-11T02:55:32Z</dc:date>
    </item>
  </channel>
</rss>

