<?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: problem to convert a character into numeric with comma in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/problem-to-convert-a-character-into-numeric-with-comma/m-p/364945#M86620</link>
    <description>&lt;P&gt;Strange, I do? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG title="Udklip.PNG" alt="Udklip.PNG" src="https://communities.sas.com/t5/image/serverpage/image-id/9252i1481ACE4FB6953A6/image-size/medium?v=1.0&amp;amp;px=-1" border="0" /&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 07 Jun 2017 12:32:59 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2017-06-07T12:32:59Z</dc:date>
    <item>
      <title>problem to convert a character into numeric with comma</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-to-convert-a-character-into-numeric-with-comma/m-p/364933#M86614</link>
      <description>&lt;P&gt;hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;in a dataset , there are 2 records and a column named "amount" &amp;nbsp;(character), and values are&lt;/P&gt;&lt;P&gt;rec&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;amount&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 82.04&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; 108498.19&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And I would like to convert these values into numeric.&lt;/P&gt;&lt;P&gt;I try input(amount,&lt;STRONG&gt;5.&lt;/STRONG&gt;) that returns 82.04 for rec1 (correct) but 10849 for rec 2(not correct because truncated)&lt;/P&gt;&lt;P&gt;I try input(amount,9&lt;STRONG&gt;.&lt;/STRONG&gt;) that returns 108498.19&amp;nbsp;for rec 2 (correct) but&amp;nbsp;"." for rec 1 (not correct)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;please, what is the correct syntax and the correct informat ?&lt;/P&gt;&lt;P&gt;thanks in advance&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jun 2017 12:10:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-to-convert-a-character-into-numeric-with-comma/m-p/364933#M86614</guid>
      <dc:creator>Nasser_DRMCP</dc:creator>
      <dc:date>2017-06-07T12:10:18Z</dc:date>
    </item>
    <item>
      <title>Re: problem to convert a character into numeric with comma</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-to-convert-a-character-into-numeric-with-comma/m-p/364935#M86616</link>
      <description>&lt;P&gt;To convert to numeric&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;amount1 = amount+0;&lt;/PRE&gt;
&lt;P&gt;To include a comma, this is done via assigning the comma format to amount1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jun 2017 12:12:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-to-convert-a-character-into-numeric-with-comma/m-p/364935#M86616</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-06-07T12:12:27Z</dc:date>
    </item>
    <item>
      <title>Re: problem to convert a character into numeric with comma</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-to-convert-a-character-into-numeric-with-comma/m-p/364936#M86617</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
length amount $10;
input rec amount$;
datalines;
1 82.04
2 108498.19
;

data want;
	set have;
	amount_num = input(amount,comma10.2);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Jun 2017 12:14:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-to-convert-a-character-into-numeric-with-comma/m-p/364936#M86617</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2017-06-07T12:14:50Z</dc:date>
    </item>
    <item>
      <title>Re: problem to convert a character into numeric with comma</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-to-convert-a-character-into-numeric-with-comma/m-p/364940#M86618</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
length amount $10;
input rec amount$;
datalines;
1 82.04
2 108498.19
;

data want;
	set have;
	amount_num = input(amount,comma10.2);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;When I execute this code and then do a proc print, I don't see the commas in amount_num.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jun 2017 12:27:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-to-convert-a-character-into-numeric-with-comma/m-p/364940#M86618</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-06-07T12:27:13Z</dc:date>
    </item>
    <item>
      <title>Re: problem to convert a character into numeric with comma</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-to-convert-a-character-into-numeric-with-comma/m-p/364943#M86619</link>
      <description>&lt;P&gt;Your INPUT function with informat should just work fine, see example below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  length amount $ 15;

  do amount = "82.04", "108498.19";
    amount_n = input(amount, 15.);
    output;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Jun 2017 12:32:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-to-convert-a-character-into-numeric-with-comma/m-p/364943#M86619</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2017-06-07T12:32:32Z</dc:date>
    </item>
    <item>
      <title>Re: problem to convert a character into numeric with comma</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-to-convert-a-character-into-numeric-with-comma/m-p/364945#M86620</link>
      <description>&lt;P&gt;Strange, I do? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG title="Udklip.PNG" alt="Udklip.PNG" src="https://communities.sas.com/t5/image/serverpage/image-id/9252i1481ACE4FB6953A6/image-size/medium?v=1.0&amp;amp;px=-1" border="0" /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jun 2017 12:32:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-to-convert-a-character-into-numeric-with-comma/m-p/364945#M86620</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2017-06-07T12:32:59Z</dc:date>
    </item>
    <item>
      <title>Re: problem to convert a character into numeric with comma</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-to-convert-a-character-into-numeric-with-comma/m-p/364946#M86621</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Strange, I do? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG title="Udklip.PNG" alt="Udklip.PNG" src="https://communities.sas.com/t5/image/serverpage/image-id/9252i1481ACE4FB6953A6/image-size/medium?v=1.0&amp;amp;px=-1" border="0" /&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Maybe there's something unusual about my computer and commas are written in invisible ink, but I do not see commas, not in my web browser looking at your reply, and not in my SAS 9.4 when I do a PROC PRINT.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jun 2017 12:38:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-to-convert-a-character-into-numeric-with-comma/m-p/364946#M86621</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-06-07T12:38:39Z</dc:date>
    </item>
    <item>
      <title>Re: problem to convert a character into numeric with comma</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-to-convert-a-character-into-numeric-with-comma/m-p/364950#M86623</link>
      <description>&lt;P&gt;Ah, I mixed them up with periods, my bad &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jun 2017 12:45:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-to-convert-a-character-into-numeric-with-comma/m-p/364950#M86623</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2017-06-07T12:45:25Z</dc:date>
    </item>
    <item>
      <title>Re: problem to convert a character into numeric with comma</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-to-convert-a-character-into-numeric-with-comma/m-p/364969#M86634</link>
      <description>&lt;P&gt;Are you reading from a text file? Make sure to use the TRUNCOVER option on the INFILE statement. &amp;nbsp;Or add the : modifier in front of the format in the INPUT statement.&lt;/P&gt;
&lt;P&gt;Are you reading from a character variable using the INPUT() function? Is so then your issue is probably caused by non-printing characters on the end of the shorter string. &amp;nbsp;Like at TAB ('09'x) or a CR ('0D'x) or perhaps a NUL ('00'x) or what Microsoft likes to call a non-breaking space ('A0'x). &amp;nbsp;Try printing the value using $HEX format to see what characters are there and then use the COMPRESS() function to remove them.&lt;/P&gt;
&lt;P&gt;If you want the value to print with commas as the thousand separators then use the COMMA format. If you want to change decimal point to a comma and use period as thousands separator then use COMMAX or change your locale settings.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
 set have ;
  amount_num = input(amount,32.);
  format amount_num comma14.2;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jun 2017 13:21:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-to-convert-a-character-into-numeric-with-comma/m-p/364969#M86634</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-06-07T13:21:24Z</dc:date>
    </item>
  </channel>
</rss>

