<?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 to numeric in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Converting-character-to-numeric/m-p/517750#M3397</link>
    <description>&lt;P&gt;Hello, I am trying to convert a character variable to a numeric variable. I used the INPUT function in the advanced expression builder, but the data that is currently a character field has commas and parenthesis in it. My guess is that I need to remove any special characters prior to converting the data to numeric.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can't change the field on import because I have to transpose the data to get it in the correct order.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;INPUT(t1.'Total Pre-Tax Book Income:'n,BEST12.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be great! I am a very new user to this program.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Brooke&lt;/P&gt;</description>
    <pubDate>Sat, 01 Dec 2018 17:12:20 GMT</pubDate>
    <dc:creator>bmenter</dc:creator>
    <dc:date>2018-12-01T17:12:20Z</dc:date>
    <item>
      <title>Converting character to numeric</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Converting-character-to-numeric/m-p/517750#M3397</link>
      <description>&lt;P&gt;Hello, I am trying to convert a character variable to a numeric variable. I used the INPUT function in the advanced expression builder, but the data that is currently a character field has commas and parenthesis in it. My guess is that I need to remove any special characters prior to converting the data to numeric.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can't change the field on import because I have to transpose the data to get it in the correct order.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;INPUT(t1.'Total Pre-Tax Book Income:'n,BEST12.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be great! I am a very new user to this program.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Brooke&lt;/P&gt;</description>
      <pubDate>Sat, 01 Dec 2018 17:12:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Converting-character-to-numeric/m-p/517750#M3397</guid>
      <dc:creator>bmenter</dc:creator>
      <dc:date>2018-12-01T17:12:20Z</dc:date>
    </item>
    <item>
      <title>Re: Converting character to numeric</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Converting-character-to-numeric/m-p/517758#M3401</link>
      <description>&lt;P&gt;I find that if I&lt;SPAN&gt; create a dummy like this I am able to convert the numbers into character&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;data have(rename=(myvar2=myvar));&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;set have&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;myvar2 &lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;input&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;myvar&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN&gt; best12&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;drop myvar;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;'&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 01 Dec 2018 18:57:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Converting-character-to-numeric/m-p/517758#M3401</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2018-12-01T18:57:34Z</dc:date>
    </item>
    <item>
      <title>Re: Converting character to numeric</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Converting-character-to-numeric/m-p/517762#M3402</link>
      <description>&lt;P&gt;Try using the COMMA informat instead.&lt;/P&gt;
&lt;P&gt;Otherwise use COMPRESS() function to remove the characters you don't want.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;input(compress(xxx,'.','kd'),32.)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Examples:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  input char $32.;
  num1=input(char,??32.);
  num2=input(char,??comma32.);
  num3=input(compress(char,'.','kd'),??32.);
cards;
123
1.3
$123
123,456
(123,456)
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;Obs    char          num1         num2        num3

 1     123          123.0        123.0       123.0
 2     1.3            1.3          1.3         1.3
 3     $123            .         123.0       123.0
 4     123,456         .      123456.0    123456.0
 5     (123,456)       .     -123456.0    123456.0&lt;/PRE&gt;</description>
      <pubDate>Sat, 01 Dec 2018 20:29:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Converting-character-to-numeric/m-p/517762#M3402</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-12-01T20:29:50Z</dc:date>
    </item>
    <item>
      <title>Re: Converting character to numeric</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Converting-character-to-numeric/m-p/518049#M3482</link>
      <description>&lt;P&gt;Hello, thank you for your solution, can you tell me what I am doing wrong? I lose the negative sign for negative values? Thank you!! I attached a screen shot of the results.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;PROC SQL;&lt;BR /&gt;CREATE TABLE WORK.OTP_PBT_AND_TAX_GRP AS&lt;BR /&gt;SELECT t1.Source,&lt;BR /&gt;t1.'Total Total Pre-Tax Book Income'n,&lt;BR /&gt;t1.'Total Tax Provision'n,&lt;BR /&gt;/* PTBI */&lt;BR /&gt;(INPUT(COMPRESS(t1.'Total Total Pre-Tax Book Income'n, ' . ' , 'kd'),BEST32.)) FORMAT=BEST32. AS PTBI,&lt;BR /&gt;/* PTBI1 */&lt;BR /&gt;(INPUT(t1.'Total Total Pre-Tax Book Income'n, BESTcomma32.)) AS PTBI1&lt;BR /&gt;FROM WORK.TRNSTRANSPOSED_0000 t1;&lt;BR /&gt;QUIT;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Dec 2018 13:20:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Converting-character-to-numeric/m-p/518049#M3482</guid>
      <dc:creator>bmenter</dc:creator>
      <dc:date>2018-12-03T13:20:05Z</dc:date>
    </item>
    <item>
      <title>Re: Converting character to numeric</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Converting-character-to-numeric/m-p/518094#M3485</link>
      <description>&lt;P&gt;Include hyphen along with period in the list of characters to keep.&lt;/P&gt;
&lt;P&gt;But if you want to read the parentheses as meaning negative value then use the COMMA informat.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Dec 2018 13:28:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Converting-character-to-numeric/m-p/518094#M3485</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-12-05T13:28:37Z</dc:date>
    </item>
  </channel>
</rss>

