<?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: substr function in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/substr-function/m-p/633997#M188143</link>
    <description>&lt;P&gt;Thanks! It works!&lt;/P&gt;</description>
    <pubDate>Sun, 22 Mar 2020 21:28:52 GMT</pubDate>
    <dc:creator>bayoote</dc:creator>
    <dc:date>2020-03-22T21:28:52Z</dc:date>
    <item>
      <title>substr function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/substr-function/m-p/633989#M188137</link>
      <description>&lt;P&gt;I have a variable has values like 0,100 miles, 200 miles,3000 miles. I want to remove the miles part.&lt;/P&gt;&lt;P&gt;I used substr function.&lt;/P&gt;&lt;P&gt;Miles_new=substr(miles,1,length(miles)-5)&lt;/P&gt;&lt;P&gt;However, it gave me the error Character has been converted to numeric values and Invalid numeric data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I fix that?&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Sun, 22 Mar 2020 20:44:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/substr-function/m-p/633989#M188137</guid>
      <dc:creator>bayoote</dc:creator>
      <dc:date>2020-03-22T20:44:30Z</dc:date>
    </item>
    <item>
      <title>Re: substr function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/substr-function/m-p/633990#M188138</link>
      <description>&lt;P&gt;Use the TRANWRD() function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Y=tranwrd(x,'Miles','');&lt;/P&gt;
&lt;DIV id="tap-translate"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Sun, 22 Mar 2020 20:49:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/substr-function/m-p/633990#M188138</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-03-22T20:49:27Z</dc:date>
    </item>
    <item>
      <title>Re: substr function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/substr-function/m-p/633991#M188139</link>
      <description>&lt;P&gt;Please post the log of your code using the {i} icon window.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can get same result by&lt;STRONG&gt; miles_new = compress(miles,,'kd');&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 22 Mar 2020 20:56:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/substr-function/m-p/633991#M188139</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2020-03-22T20:56:27Z</dc:date>
    </item>
    <item>
      <title>Re: substr function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/substr-function/m-p/633993#M188140</link>
      <description>&lt;P&gt;Use COMPRESS() to remove all alphabetic characters from the string and keep only the numbers.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/311914"&gt;@bayoote&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have a variable has values like 0,100 miles, 200 miles,3000 miles. I want to remove the miles part.&lt;/P&gt;
&lt;P&gt;I used substr function.&lt;/P&gt;
&lt;P&gt;Miles_new=substr(miles,1,length(miles)-5)&lt;/P&gt;
&lt;P&gt;However, it gave me the error Character has been converted to numeric values and Invalid numeric data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can I fix that?&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 22 Mar 2020 21:06:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/substr-function/m-p/633993#M188140</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-03-22T21:06:49Z</dc:date>
    </item>
    <item>
      <title>Re: substr function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/substr-function/m-p/633995#M188141</link>
      <description>&lt;P&gt;The&amp;nbsp; difference between TRANWRD and COMPRESS is that COMPRESS will remove all characters specified, rather than just the word "Miles", as in the original request. For this problem, maybe both work, but in general you can't interchange COMPRESS and TRANWRD.&lt;/P&gt;
&lt;DIV id="tap-translate"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Sun, 22 Mar 2020 21:09:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/substr-function/m-p/633995#M188141</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-03-22T21:09:43Z</dc:date>
    </item>
    <item>
      <title>Re: substr function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/substr-function/m-p/633997#M188143</link>
      <description>&lt;P&gt;Thanks! It works!&lt;/P&gt;</description>
      <pubDate>Sun, 22 Mar 2020 21:28:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/substr-function/m-p/633997#M188143</guid>
      <dc:creator>bayoote</dc:creator>
      <dc:date>2020-03-22T21:28:52Z</dc:date>
    </item>
    <item>
      <title>Re: substr function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/substr-function/m-p/633998#M188144</link>
      <description>&lt;P&gt;Below code will convert your source string into a numerical variable and though allow you to use it for calculations.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  infile datalines truncover;
  input miles $20.;
  datalines;
0,100 miles
200 miles
000 miles
;

data want;
  set have;
  miles_new=input(scan(miles,1,' '),commax16.);
run;

proc print data=want;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 22 Mar 2020 21:33:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/substr-function/m-p/633998#M188144</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-03-22T21:33:46Z</dc:date>
    </item>
  </channel>
</rss>

