<?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 characters to numeric in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Convert-characters-to-numeric/m-p/377266#M276499</link>
    <description>&lt;P&gt;In future, please mark the appropriate post as the correct answer, not your reply to it.&lt;/P&gt;</description>
    <pubDate>Wed, 19 Jul 2017 12:10:19 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2017-07-19T12:10:19Z</dc:date>
    <item>
      <title>Convert characters to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-characters-to-numeric/m-p/375619#M276495</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have input data that looks like these -&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Size &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Space &amp;nbsp; &amp;nbsp; Date&lt;/P&gt;&lt;P&gt;840K &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;7% &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2017.183&lt;/P&gt;&lt;P&gt;23433K &amp;nbsp; &amp;nbsp;25% &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2013.034&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The "K" probably is 1000 or 1024 - I take the value as 1000. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have not seen any INFORMATS that can convert 840K to 840000 (numeric value) or 7% to 0.07 (numeric value). &amp;nbsp;The date has a "." in between the year and day (in Julian format). &amp;nbsp;I need to convert the date to SAS internal date. &amp;nbsp;Again, I went looking at the INFORMATS available - but, I can't see any suitable ones.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I understand the coding required (for example) -&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SIZEN = INPUT (SIZE. informat);&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It is trying to look for a proper informat that gives me the problems.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;TS&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jul 2017 11:13:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-characters-to-numeric/m-p/375619#M276495</guid>
      <dc:creator>TingSern</dc:creator>
      <dc:date>2017-07-13T11:13:11Z</dc:date>
    </item>
    <item>
      <title>Re: Convert characters to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-characters-to-numeric/m-p/375626#M276496</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
infile cards firstobs=2;
format size 10. space 7.2 date date9.;
input size_string $ space :percent7. date_string :$10.;
date = input(compress(date_string,'.'),julian8.);
pos = notdigit(trim(size_string));
size = input(substr(size_string,1,pos-1),10.);
select (substr(size_string,pos,1));
  when ('K') size = size * 1024;
end;
drop size_string date_string pos;
cards;
Size         Space     Date
840K        7%          2017.183
23433K    25%        2013.034
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You just have to "fit" the data for the proper formats. How eg the input for the JULIANw. format has to look can be taken from the documentation.&lt;/P&gt;
&lt;P&gt;The documentation can usually be found by googling "SAS 9.4" and the keyword, or something like "SAS 9.4 informats by category".&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jul 2017 11:23:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-characters-to-numeric/m-p/375626#M276496</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-07-13T11:23:28Z</dc:date>
    </item>
    <item>
      <title>Re: Convert characters to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-characters-to-numeric/m-p/375630#M276497</link>
      <description>&lt;P&gt;Well, the first is simple:&lt;/P&gt;
&lt;PRE&gt;sizen=input(tranwrd(size,"Z","000"),best.);
&lt;/PRE&gt;
&lt;P&gt;The date:&lt;/P&gt;
&lt;PRE&gt;new_date=input(compress(date,"."),julian7.);
&lt;/PRE&gt;</description>
      <pubDate>Thu, 13 Jul 2017 11:26:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-characters-to-numeric/m-p/375630#M276497</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-07-13T11:26:09Z</dc:date>
    </item>
    <item>
      <title>Re: Convert characters to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-characters-to-numeric/m-p/377256#M276498</link>
      <description>&lt;P&gt;Yes - this is the right solution.&amp;nbsp; Thank you.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jul 2017 11:25:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-characters-to-numeric/m-p/377256#M276498</guid>
      <dc:creator>TingSern</dc:creator>
      <dc:date>2017-07-19T11:25:38Z</dc:date>
    </item>
    <item>
      <title>Re: Convert characters to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-characters-to-numeric/m-p/377266#M276499</link>
      <description>&lt;P&gt;In future, please mark the appropriate post as the correct answer, not your reply to it.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jul 2017 12:10:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-characters-to-numeric/m-p/377266#M276499</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-07-19T12:10:19Z</dc:date>
    </item>
  </channel>
</rss>

