<?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 $50. to numeric in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/convert-50-to-numeric/m-p/850349#M82380</link>
    <description>&lt;P&gt;If the number has 50 digits, converting it to numeric will cause loss of precision.&lt;/P&gt;</description>
    <pubDate>Mon, 19 Dec 2022 14:34:27 GMT</pubDate>
    <dc:creator>andreas_lds</dc:creator>
    <dc:date>2022-12-19T14:34:27Z</dc:date>
    <item>
      <title>convert $50. to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/convert-50-to-numeric/m-p/850253#M82377</link>
      <description>&lt;P&gt;Hello I want to convert&amp;nbsp;$50. to numeric. this is the dataset. when I run proc corr I have a error in the log "in list does not match type prescribed for this list"&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sasphd_0-1671383569943.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/78672i6BFC4A4D4016BC0B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="sasphd_0-1671383569943.png" alt="sasphd_0-1671383569943.png" /&gt;&lt;/span&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Sun, 18 Dec 2022 17:14:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/convert-50-to-numeric/m-p/850253#M82377</guid>
      <dc:creator>sasphd</dc:creator>
      <dc:date>2022-12-18T17:14:23Z</dc:date>
    </item>
    <item>
      <title>Re: convert $50. to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/convert-50-to-numeric/m-p/850254#M82378</link>
      <description>&lt;P&gt;Use the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.2/lefunctionsref/p19en16vskd2vhn1vwmxpxnglxxs.htm" target="_self"&gt;Input Function&lt;/A&gt; with an appropriate informat.&lt;/P&gt;</description>
      <pubDate>Sun, 18 Dec 2022 18:22:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/convert-50-to-numeric/m-p/850254#M82378</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-12-18T18:22:28Z</dc:date>
    </item>
    <item>
      <title>Re: convert $50. to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/convert-50-to-numeric/m-p/850283#M82379</link>
      <description>&lt;P&gt;The INPUT function is the preferred method, but here are a few more considerations.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First, you will need new variable names.&amp;nbsp; Existing character variables cannot be turned into numeric variables.&amp;nbsp; You could conceivably jump through some hoops to re-use the old names, which could look like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   set have;
   numvar = input(charvar, 20.);
   drop charvar;
   rename numvar = charvar;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;That would give you the original variable name as a numeric variable, but it's a tedious process to go through if you have many variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second, you can trade off complexities of the programming if you are willing to tolerate notes in the log:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   set have;  
   length numvar 8;
   numvar = charvar;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;That gives you NUMVAR as the numeric version of CHARVAR, but adds a note to the log about character to numeric conversion.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Finally, if you use the INPUT function, do not add number of decimal places:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   set have;
   numvar = input(charvar, 6.4);     /* gives the wrong result */
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Just supply the width to the INPUT function, not the number of positions after the decimal point.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Dec 2022 01:02:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/convert-50-to-numeric/m-p/850283#M82379</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2022-12-19T01:02:29Z</dc:date>
    </item>
    <item>
      <title>Re: convert $50. to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/convert-50-to-numeric/m-p/850349#M82380</link>
      <description>&lt;P&gt;If the number has 50 digits, converting it to numeric will cause loss of precision.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Dec 2022 14:34:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/convert-50-to-numeric/m-p/850349#M82380</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2022-12-19T14:34:27Z</dc:date>
    </item>
  </channel>
</rss>

