<?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: converting character to numeric variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/converting-character-to-numeric-variable/m-p/91919#M19395</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;is&amp;nbsp; any other way to retain the decimai numbers&amp;nbsp; specifically 1.0 and 1.0000&amp;nbsp; during the conversion from character to numeric? &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 11 Oct 2012 14:01:49 GMT</pubDate>
    <dc:creator>Senthil1102</dc:creator>
    <dc:date>2012-10-11T14:01:49Z</dc:date>
    <item>
      <title>converting character to numeric variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/converting-character-to-numeric-variable/m-p/91916#M19392</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; i had a character variable with the following values...&lt;BR /&gt;1.0&lt;BR /&gt;2.123&lt;BR /&gt;1.222&lt;BR /&gt;1.0000&lt;BR /&gt;3.1022&lt;/P&gt;&lt;P&gt;while converting it to numeric variable, the trailing zeros are disappeared...is there any way to retain the exact decimal numbers while converting from character to numeric variable...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1&lt;/P&gt;&lt;P&gt;2.123&lt;/P&gt;&lt;P&gt;1.222&lt;/P&gt;&lt;P&gt;1&lt;/P&gt;&lt;P&gt;3.1022&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Oct 2012 05:49:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/converting-character-to-numeric-variable/m-p/91916#M19392</guid>
      <dc:creator>Senthil1102</dc:creator>
      <dc:date>2012-10-11T05:49:10Z</dc:date>
    </item>
    <item>
      <title>Re: converting character to numeric variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/converting-character-to-numeric-variable/m-p/91917#M19393</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;SAS stores numbers as floating point, so there is no difference in how it is stored between the numbers 1.0 and 1.0000 in your example input stream. You can use a FORMAT to tell SAS how to display the number, but the same format will be applied to every observation in the data. For your example data you could use the format 6.4 (which can also be written as F6.4).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data test;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp; input char $ @@;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp; num = input(char,6.4);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp; put char= num= num= 6.4 ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;cards;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;1.0 2.123 1.222 1.0000 3.1022&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;char=1.0 num=1 num=1.0000&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;char=2.123 num=2.123 num=2.1230&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;char=1.222 num=1.222 num=1.2220&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;char=1.0000 num=1 num=1.0000&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;char=3.1022 num=3.1022 num=3.1022&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Oct 2012 11:22:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/converting-character-to-numeric-variable/m-p/91917#M19393</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-10-11T11:22:18Z</dc:date>
    </item>
    <item>
      <title>Re: converting character to numeric variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/converting-character-to-numeric-variable/m-p/91918#M19394</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can count the number of decimals in the character string.&amp;nbsp; What you do with that information is up to you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;DIV style="font-family: Courier New; font-size: 11pt;"&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;data&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; dec;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;input&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; c $;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; index(c,&lt;/SPAN&gt;&lt;SPAN style="color: #800080; background-color: #ffffff;"&gt;'.'&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;) &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;then&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; d = length(scan(c,-&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;1&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #800080; background-color: #ffffff;"&gt;'.'&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;));&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;else&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; d = &lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;0&lt;/STRONG&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; num = input(c,&lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;f12.&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;);&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;cards&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffc0;"&gt;1.0&lt;BR /&gt;2.123&lt;BR /&gt;1.222&lt;BR /&gt;1.0000&lt;BR /&gt;3.1022&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;;;;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;run&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Oct 2012 12:53:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/converting-character-to-numeric-variable/m-p/91918#M19394</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2012-10-11T12:53:37Z</dc:date>
    </item>
    <item>
      <title>Re: converting character to numeric variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/converting-character-to-numeric-variable/m-p/91919#M19395</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;is&amp;nbsp; any other way to retain the decimai numbers&amp;nbsp; specifically 1.0 and 1.0000&amp;nbsp; during the conversion from character to numeric? &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Oct 2012 14:01:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/converting-character-to-numeric-variable/m-p/91919#M19395</guid>
      <dc:creator>Senthil1102</dc:creator>
      <dc:date>2012-10-11T14:01:49Z</dc:date>
    </item>
    <item>
      <title>Re: converting character to numeric variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/converting-character-to-numeric-variable/m-p/91920#M19396</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;To follow-on what data_null_ stated ("What you do with that information is up to you.") I think it would be helpful to describe why you want to do this.&amp;nbsp; It would seem that if you need it both numeric and character, then you keep both variables and use the one that's needed at the time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example if the objective is to line up the decimal places so that you get something like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; 1.000&lt;/P&gt;&lt;P&gt;31.2&lt;/P&gt;&lt;P&gt;&amp;nbsp; 0.00012220000&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then you would need to create an additional character string with a fixed length and the decimal would always show in the same position of the character string.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Oct 2012 21:19:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/converting-character-to-numeric-variable/m-p/91920#M19396</guid>
      <dc:creator>jbaldwin</dc:creator>
      <dc:date>2012-10-11T21:19:51Z</dc:date>
    </item>
  </channel>
</rss>

