<?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 char values to numeric values in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Convert-char-values-to-numeric-values/m-p/53054#M14619</link>
    <description>Hi Lani,&lt;BR /&gt;
&lt;BR /&gt;
See here you are assigning the length of the string as 10 to the variable char Amount.&lt;BR /&gt;
When you apply the comma10.2 to read it in input statement it will take the last two digits as the digits after decimal point.&lt;BR /&gt;
for example:&lt;BR /&gt;
&lt;BR /&gt;
&lt;B&gt;data test;&lt;BR /&gt;
input chars $10.;&lt;BR /&gt;
cards;&lt;BR /&gt;
$1,100.100 &lt;BR /&gt;
$1000.0000 &lt;BR /&gt;
$59,000.00 &lt;BR /&gt;
$59.000000&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data temp;&lt;BR /&gt;
set test;&lt;BR /&gt;
newnum=input(chars,dollar10.2);&lt;BR /&gt;
run;&lt;BR /&gt;
proc print;&lt;BR /&gt;
run;&lt;/B&gt;&lt;BR /&gt;
&lt;BR /&gt;
Running the above code will give you the right result. since the length is exactly 10  chars.&lt;BR /&gt;
&lt;BR /&gt;
If you want to get the desired result on the data which you have provided just use comma10. or dollar10. format and not the decimal part of the formats.&lt;BR /&gt;
Try following this code:&lt;BR /&gt;
&lt;I&gt;&lt;B&gt;&lt;BR /&gt;
data test;&lt;BR /&gt;
input chars $10.;&lt;BR /&gt;
cards;&lt;BR /&gt;
$1,100.1 &lt;BR /&gt;
$1000&lt;BR /&gt;
$59,000&lt;BR /&gt;
$59&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data temp;&lt;BR /&gt;
format newnum 10.2;&lt;BR /&gt;
set test;&lt;BR /&gt;
newnum=input(chars,dollar10.);&lt;BR /&gt;
run;&lt;BR /&gt;
proc print;&lt;BR /&gt;
run;&lt;/B&gt;&lt;/I&gt;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Thanks,&lt;BR /&gt;
Saurabh.

Message was edited by: emerald85</description>
    <pubDate>Fri, 12 Feb 2010 06:39:41 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2010-02-12T06:39:41Z</dc:date>
    <item>
      <title>Convert char values to numeric values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Convert-char-values-to-numeric-values/m-p/53052#M14617</link>
      <description>Hi all,&lt;BR /&gt;
&lt;BR /&gt;
I am trying to remove "$", "," and then convert from char values to numeric values&lt;BR /&gt;
&lt;BR /&gt;
amount (from input data)             &lt;BR /&gt;
 $1,100.1                      &lt;BR /&gt;
 $1000                          &lt;BR /&gt;
 $59,000                     &lt;BR /&gt;
 $59                                &lt;BR /&gt;
&lt;BR /&gt;
n_amount (the output)&lt;BR /&gt;
  1100.10&lt;BR /&gt;
  1000.00&lt;BR /&gt;
 59000.00  &lt;BR /&gt;
      59.00&lt;BR /&gt;
&lt;BR /&gt;
my codes:&lt;BR /&gt;
attrib amount      length=$10.&lt;BR /&gt;
        n_amount   length=10.;&lt;BR /&gt;
&lt;BR /&gt;
n_amount = input(amount,comma10.2);&lt;BR /&gt;
&lt;BR /&gt;
However, the output I got: &lt;BR /&gt;
n_amount&lt;BR /&gt;
 1100.1&lt;BR /&gt;
       10&lt;BR /&gt;
     590&lt;BR /&gt;
     0.59&lt;BR /&gt;
&lt;BR /&gt;
Please help! Thank you.&lt;BR /&gt;
&lt;BR /&gt;
-Lani</description>
      <pubDate>Fri, 05 Feb 2010 01:07:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Convert-char-values-to-numeric-values/m-p/53052#M14617</guid>
      <dc:creator>Lani</dc:creator>
      <dc:date>2010-02-05T01:07:48Z</dc:date>
    </item>
    <item>
      <title>Re: Convert char values to numeric values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Convert-char-values-to-numeric-values/m-p/53053#M14618</link>
      <description>Where is your INPUT statement logic to read up your data and assign a SAS character variable?  It's best to share all your SAS code and ideally share it in a SAS session log (pasted in your post/reply).&lt;BR /&gt;
&lt;BR /&gt;
You can add SAS PUTLOG _ALL_;  commands to display all variable values - this may help you self-diagnose the situation.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Fri, 05 Feb 2010 01:18:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Convert-char-values-to-numeric-values/m-p/53053#M14618</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-02-05T01:18:58Z</dc:date>
    </item>
    <item>
      <title>Re: Convert char values to numeric values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Convert-char-values-to-numeric-values/m-p/53054#M14619</link>
      <description>Hi Lani,&lt;BR /&gt;
&lt;BR /&gt;
See here you are assigning the length of the string as 10 to the variable char Amount.&lt;BR /&gt;
When you apply the comma10.2 to read it in input statement it will take the last two digits as the digits after decimal point.&lt;BR /&gt;
for example:&lt;BR /&gt;
&lt;BR /&gt;
&lt;B&gt;data test;&lt;BR /&gt;
input chars $10.;&lt;BR /&gt;
cards;&lt;BR /&gt;
$1,100.100 &lt;BR /&gt;
$1000.0000 &lt;BR /&gt;
$59,000.00 &lt;BR /&gt;
$59.000000&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data temp;&lt;BR /&gt;
set test;&lt;BR /&gt;
newnum=input(chars,dollar10.2);&lt;BR /&gt;
run;&lt;BR /&gt;
proc print;&lt;BR /&gt;
run;&lt;/B&gt;&lt;BR /&gt;
&lt;BR /&gt;
Running the above code will give you the right result. since the length is exactly 10  chars.&lt;BR /&gt;
&lt;BR /&gt;
If you want to get the desired result on the data which you have provided just use comma10. or dollar10. format and not the decimal part of the formats.&lt;BR /&gt;
Try following this code:&lt;BR /&gt;
&lt;I&gt;&lt;B&gt;&lt;BR /&gt;
data test;&lt;BR /&gt;
input chars $10.;&lt;BR /&gt;
cards;&lt;BR /&gt;
$1,100.1 &lt;BR /&gt;
$1000&lt;BR /&gt;
$59,000&lt;BR /&gt;
$59&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data temp;&lt;BR /&gt;
format newnum 10.2;&lt;BR /&gt;
set test;&lt;BR /&gt;
newnum=input(chars,dollar10.);&lt;BR /&gt;
run;&lt;BR /&gt;
proc print;&lt;BR /&gt;
run;&lt;/B&gt;&lt;/I&gt;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Thanks,&lt;BR /&gt;
Saurabh.

Message was edited by: emerald85</description>
      <pubDate>Fri, 12 Feb 2010 06:39:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Convert-char-values-to-numeric-values/m-p/53054#M14619</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-02-12T06:39:41Z</dc:date>
    </item>
  </channel>
</rss>

