<?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 char to num in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Converting-char-to-num/m-p/467629#M119383</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/89963"&gt;@_sas&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello Everyone,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want 100.10 as a value of variable e. is it possible without using any format ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;SAS data step being turing-complete, it is of course possible. See here:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
have = '100.10';
want = 0;
fr_count = .;
do i = 1 to length(have);
  if substr(have,i,1) = '.'
  then fr_count = 0;
  else do;
    want = want * 10 + rank(substr(have,i,1)) - 48;
    if fr_count ne . then fr_count + 1;
  end;
end;
if fr_count ne . then want = want / 10 ** fr_count;  
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that I did this because sometimes I have enough time at hand to waste on stupid ideas &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 05 Jun 2018 11:42:18 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2018-06-05T11:42:18Z</dc:date>
    <item>
      <title>Converting char to num</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-char-to-num/m-p/467612#M119376</link>
      <description>&lt;P&gt;Hello Everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want 100.10 as a value of variable e. is it possible without using any format ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;b="100.1";&lt;BR /&gt;c=input(b,5.2);&lt;/P&gt;&lt;P&gt;d="100.10";&lt;BR /&gt;e=input(b,6.2);&lt;/P&gt;&lt;P&gt;put _all_;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 440px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/21000iEE41626C56E886EE/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jun 2018 10:42:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-char-to-num/m-p/467612#M119376</guid>
      <dc:creator>_sas</dc:creator>
      <dc:date>2018-06-05T10:42:19Z</dc:date>
    </item>
    <item>
      <title>Re: Converting char to num</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-char-to-num/m-p/467627#M119382</link>
      <description>&lt;P&gt;No, it's not possible.&amp;nbsp; Numbers do not contain a set of characters in SAS.&amp;nbsp; Numbers store a numeric value, not the form in which it is expressed.&amp;nbsp; You can always add a FORMAT statement later, when printing the numeric variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just for the record, your INPUT functions are treading on dangerous ground.&amp;nbsp; You would be safer using:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;b="100.1";&lt;BR /&gt;c=input(b,5.);&lt;/P&gt;
&lt;P&gt;d="100.10";&lt;BR /&gt;e=input(b,6.);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To see why, try this (and read the documentation):&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;b="12345";&lt;BR /&gt;c=input(b,5.2);&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jun 2018 11:24:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-char-to-num/m-p/467627#M119382</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-06-05T11:24:43Z</dc:date>
    </item>
    <item>
      <title>Re: Converting char to num</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-char-to-num/m-p/467629#M119383</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/89963"&gt;@_sas&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello Everyone,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want 100.10 as a value of variable e. is it possible without using any format ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;SAS data step being turing-complete, it is of course possible. See here:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
have = '100.10';
want = 0;
fr_count = .;
do i = 1 to length(have);
  if substr(have,i,1) = '.'
  then fr_count = 0;
  else do;
    want = want * 10 + rank(substr(have,i,1)) - 48;
    if fr_count ne . then fr_count + 1;
  end;
end;
if fr_count ne . then want = want / 10 ** fr_count;  
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that I did this because sometimes I have enough time at hand to waste on stupid ideas &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jun 2018 11:42:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-char-to-num/m-p/467629#M119383</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-06-05T11:42:18Z</dc:date>
    </item>
    <item>
      <title>Re: Converting char to num</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-char-to-num/m-p/467639#M119390</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;

b="100.1";
c=b+0;


put _all_;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Jun 2018 12:30:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-char-to-num/m-p/467639#M119390</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-06-05T12:30:13Z</dc:date>
    </item>
  </channel>
</rss>

