<?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 converting character values to numeric values in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/converting-character-values-to-numeric-values/m-p/345525#M79492</link>
    <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;May you help with following converting the characer value with decimal into numeric value:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;test = input( price, best12.) , it did not work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Price: &amp;nbsp;Format $7, informat $7. &amp;nbsp;&lt;/P&gt;&lt;P&gt;example of price : &amp;nbsp;6.32, &amp;nbsp;0.11, &amp;nbsp;0.44, 11.73&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;Ivy&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 29 Mar 2017 20:12:47 GMT</pubDate>
    <dc:creator>Ivy</dc:creator>
    <dc:date>2017-03-29T20:12:47Z</dc:date>
    <item>
      <title>converting character values to numeric values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/converting-character-values-to-numeric-values/m-p/345525#M79492</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;May you help with following converting the characer value with decimal into numeric value:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;test = input( price, best12.) , it did not work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Price: &amp;nbsp;Format $7, informat $7. &amp;nbsp;&lt;/P&gt;&lt;P&gt;example of price : &amp;nbsp;6.32, &amp;nbsp;0.11, &amp;nbsp;0.44, 11.73&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;Ivy&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Mar 2017 20:12:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/converting-character-values-to-numeric-values/m-p/345525#M79492</guid>
      <dc:creator>Ivy</dc:creator>
      <dc:date>2017-03-29T20:12:47Z</dc:date>
    </item>
    <item>
      <title>Re: converting character values to numeric values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/converting-character-values-to-numeric-values/m-p/345528#M79493</link>
      <description>&lt;P&gt;Works for me. I'd have to think that you entered something wrong (e.g., missing semi-colon or the like).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The following works:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data have;
  format  price $7.;
  informat price $7.;
  input price;
  cards;
6.32
0.11
0.44
11.73
;

data want;
  set have;
  test = input( price, best12.);
run;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Mar 2017 20:28:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/converting-character-values-to-numeric-values/m-p/345528#M79493</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-03-29T20:28:53Z</dc:date>
    </item>
    <item>
      <title>Re: converting character values to numeric values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/converting-character-values-to-numeric-values/m-p/345529#M79494</link>
      <description>&lt;P&gt;Your example statement should work. &amp;nbsp;Make sure that your text string does not have non-printing characters like tabs, carriage returns or non-breaking spaces ('09'x,'0A'x,'A0'x, respectively).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
  length price $7 ;
  input price ;
  test = input(price, 7.);
cards;
6.32
0.11
0.44
11.73
;;;;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;A couple of notes.&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;The LENGTH of a character variable is more important than what FORMAT or INFORMAT is attached to it. &amp;nbsp;In fact the FORMAT can actually cause trouble if it doesn't match the length since it can make it hard to debug.&lt;/LI&gt;
&lt;LI&gt;BEST is really a FORMAT and not an INFORMAT. &amp;nbsp;SAS will just use the 12. INFORMAT if you ask it to use BEST12. as in informat. Actually for reading text into numbers the COMMA informat is good one to use because it will ignore dollar signs and commas in your strings. &amp;nbsp;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;To see if your strings have non-printing characters print the value using $HEX format. '20'X is the code for a space.&lt;/P&gt;
&lt;P&gt;Or you the COMPRESS() function to remove non digits. &amp;nbsp;Something like this might help.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;test = input(COMPRESS(price, "+.-", "d"),32.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Mar 2017 20:31:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/converting-character-values-to-numeric-values/m-p/345529#M79494</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-03-29T20:31:16Z</dc:date>
    </item>
    <item>
      <title>Re: converting character values to numeric values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/converting-character-values-to-numeric-values/m-p/345531#M79495</link>
      <description>&lt;P&gt;Doesn't work is awful vague.&lt;BR /&gt;&lt;BR /&gt;Are there errors in the log: Post the code and log in a code box opened with the {i} to maintain formatting of error messages.&lt;BR /&gt;&lt;BR /&gt;No output? Post any log in a code box.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Unexpected output? Provide input data in the form of a dataset, the actual results and the expected results. Data should be in the form of a data step. Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat&lt;/A&gt;... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also is your value for Price= '6.32' or '$6.32'? or does your Price have values separated by commas? Leading spaces? It isn't quite clear from your example.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Mar 2017 20:32:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/converting-character-values-to-numeric-values/m-p/345531#M79495</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-03-29T20:32:12Z</dc:date>
    </item>
    <item>
      <title>Re: converting character values to numeric values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/converting-character-values-to-numeric-values/m-p/345608#M79518</link>
      <description>Thank you very much. There is special character in the column which made it did not work.</description>
      <pubDate>Thu, 30 Mar 2017 01:25:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/converting-character-values-to-numeric-values/m-p/345608#M79518</guid>
      <dc:creator>Ivy</dc:creator>
      <dc:date>2017-03-30T01:25:58Z</dc:date>
    </item>
    <item>
      <title>Re: converting character values to numeric values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/converting-character-values-to-numeric-values/m-p/345609#M79519</link>
      <description>Thank you , the special non-printing character in the column made that did not work.</description>
      <pubDate>Thu, 30 Mar 2017 01:27:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/converting-character-values-to-numeric-values/m-p/345609#M79519</guid>
      <dc:creator>Ivy</dc:creator>
      <dc:date>2017-03-30T01:27:35Z</dc:date>
    </item>
    <item>
      <title>Re: converting character values to numeric values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/converting-character-values-to-numeric-values/m-p/345610#M79520</link>
      <description>Thank you !</description>
      <pubDate>Thu, 30 Mar 2017 01:27:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/converting-character-values-to-numeric-values/m-p/345610#M79520</guid>
      <dc:creator>Ivy</dc:creator>
      <dc:date>2017-03-30T01:27:45Z</dc:date>
    </item>
  </channel>
</rss>

