<?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: Deleting characters at the end when the string has a delimiter and different lengths in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Deleting-characters-at-the-end-when-the-string-has-a-delimiter/m-p/542482#M7550</link>
    <description>&lt;P&gt;That worked.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Tue, 12 Mar 2019 16:20:34 GMT</pubDate>
    <dc:creator>hein68</dc:creator>
    <dc:date>2019-03-12T16:20:34Z</dc:date>
    <item>
      <title>Deleting characters at the end when the string has a delimiter and different lengths</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Deleting-characters-at-the-end-when-the-string-has-a-delimiter/m-p/541623#M7389</link>
      <description>&lt;P&gt;Hello.&amp;nbsp; I need to delete&amp;nbsp;&lt;FONT&gt;characters at the end when the string has a delimiter and different lengths.&amp;nbsp; Here are two examples of my data values:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT&gt;114wr01_ws02_2_3_MA_6_27_17&lt;BR /&gt;123abr01_abs03_2_1_CC_7_12_17&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT&gt;I need to delete the 4th underscore and everything after it.&amp;nbsp; What would be the easiest way to do this?&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT&gt;Thanks.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Mar 2019 21:37:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Deleting-characters-at-the-end-when-the-string-has-a-delimiter/m-p/541623#M7389</guid>
      <dc:creator>hein68</dc:creator>
      <dc:date>2019-03-08T21:37:55Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting characters at the end when the string has a delimiter and different lengths</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Deleting-characters-at-the-end-when-the-string-has-a-delimiter/m-p/541630#M7392</link>
      <description>&lt;P&gt;Don't know if this is the easiest but the code is relatively short:&lt;/P&gt;
&lt;PRE&gt;data example;
   x='114wr01_ws02_2_3_MA_6_27_17';
   call scan(x,4,pos,l,'_');
   y = substr(x,1,pos);
   drop pos l;
run;&lt;/PRE&gt;
&lt;P&gt;I create a new variable with the SUBSTR function so you can check if the result is what you need.&lt;/P&gt;
&lt;P&gt;call scan returns both the position and length&amp;nbsp;of the of&amp;nbsp;the nth, the 4 above,&amp;nbsp;word delimited by characters in the last list.&lt;/P&gt;
&lt;P&gt;Drop removes the temporary variables created by call scan after use.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Mar 2019 22:04:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Deleting-characters-at-the-end-when-the-string-has-a-delimiter/m-p/541630#M7392</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-03-08T22:04:57Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting characters at the end when the string has a delimiter and different lengths</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Deleting-characters-at-the-end-when-the-string-has-a-delimiter/m-p/541737#M7410</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt; , your code returns up to the first character of the fourth word. What's required is more like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data example;
   do x= '114wr01_ws02_2_3xx_MA_6_27_17', '114wr01_ws02_2_3x', '114wr01_ws02_2';
       call scan(x, 4, pos,len,'_');
       if pos &amp;gt; 0 then y = substr(x, 1, pos+len-1);
       else y = x;
       output;
       end;
   drop pos len;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 09 Mar 2019 21:39:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Deleting-characters-at-the-end-when-the-string-has-a-delimiter/m-p/541737#M7410</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2019-03-09T21:39:56Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting characters at the end when the string has a delimiter and different lengths</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Deleting-characters-at-the-end-when-the-string-has-a-delimiter/m-p/542141#M7490</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt; , your code returns up to the first character of the fourth word. What's required is more like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data example;
   do x= '114wr01_ws02_2_3xx_MA_6_27_17', '114wr01_ws02_2_3x', '114wr01_ws02_2';
       call scan(x, 4, pos,len,'_');
       if pos &amp;gt; 0 then y = substr(x, 1, pos+len-1);
       else y = x;
       output;
       end;
   drop pos len;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Agreed if there are cases where there are not 4 "words".&lt;/P&gt;
&lt;P&gt;Examples did not indicate this to be the case.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Mar 2019 17:36:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Deleting-characters-at-the-end-when-the-string-has-a-delimiter/m-p/542141#M7490</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-03-11T17:36:56Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting characters at the end when the string has a delimiter and different lengths</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Deleting-characters-at-the-end-when-the-string-has-a-delimiter/m-p/542482#M7550</link>
      <description>&lt;P&gt;That worked.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 12 Mar 2019 16:20:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Deleting-characters-at-the-end-when-the-string-has-a-delimiter/m-p/542482#M7550</guid>
      <dc:creator>hein68</dc:creator>
      <dc:date>2019-03-12T16:20:34Z</dc:date>
    </item>
  </channel>
</rss>

