<?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: Removing Characters before a Specific String in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Removing-Characters-before-a-Specific-String/m-p/442623#M282548</link>
    <description>&lt;P&gt;Great Thanks!&lt;/P&gt;</description>
    <pubDate>Mon, 05 Mar 2018 20:52:23 GMT</pubDate>
    <dc:creator>NW_SAS</dc:creator>
    <dc:date>2018-03-05T20:52:23Z</dc:date>
    <item>
      <title>Removing Characters before a Specific String</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-Characters-before-a-Specific-String/m-p/440687#M282540</link>
      <description>&lt;P&gt;I need a solution to remove all characters to the left of a&amp;nbsp;specific string. See the example below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the following transaction codes and need a way to isolate the portion of the string beginning with "4122":&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Input Transaction Codes:&lt;/P&gt;&lt;P&gt;601412265320&lt;/P&gt;&lt;P&gt;714122892335&lt;/P&gt;&lt;P&gt;507741225009964&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Desired Output Codes:&lt;/P&gt;&lt;P&gt;412265320&lt;/P&gt;&lt;P&gt;4122892335&lt;/P&gt;&lt;P&gt;41225009964&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The solution can use the following assumptions:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;I am using Version 7.12 of SAS Enterprise Guide&lt;/LI&gt;&lt;LI&gt;The Transaction Codes are character variables&lt;/LI&gt;&lt;LI&gt;Every Transaction Code will&amp;nbsp;include the string "4122"&lt;/LI&gt;&lt;LI&gt;The string "4122" will only appear once in each Transaction Code&lt;/LI&gt;&lt;LI&gt;The&amp;nbsp;number of characters&amp;nbsp;on either side of the "4122" string can vary.&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;The SCAN Function doesn't&amp;nbsp;seem to work when I tried a multi-character delimiter (It treated 4, 1, &amp;amp; 2 as separate delimiters). If I can use "4122" as delimiter and pull the portion of the Transaction Code to the&amp;nbsp;right of "4122" I can just concatenate "4122" back on the string later on. However, if there is a solution that directly generates the&amp;nbsp;desired output code&amp;nbsp;including "4122" that would be preferred.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;NW&lt;/P&gt;</description>
      <pubDate>Tue, 27 Feb 2018 22:38:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-Characters-before-a-Specific-String/m-p/440687#M282540</guid>
      <dc:creator>NW_SAS</dc:creator>
      <dc:date>2018-02-27T22:38:12Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Characters before a Specific String</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-Characters-before-a-Specific-String/m-p/440688#M282541</link>
      <description>&lt;P&gt;Use INDEX() to find the string&lt;/P&gt;
&lt;P&gt;Use the result from INDEX along with the SUBSTR() function to selection the desired portion.&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/196042"&gt;@NW_SAS&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I need a solution to remove all characters to the left of a&amp;nbsp;specific string. See the example below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have the following transaction codes and need a way to isolate the portion of the string beginning with "4122":&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Input Transaction Codes:&lt;/P&gt;
&lt;P&gt;601412265320&lt;/P&gt;
&lt;P&gt;714122892335&lt;/P&gt;
&lt;P&gt;507741225009964&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Desired Output Codes:&lt;/P&gt;
&lt;P&gt;412265320&lt;/P&gt;
&lt;P&gt;4122892335&lt;/P&gt;
&lt;P&gt;41225009964&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The solution can use the following assumptions:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;I am using Version 7.12 of SAS Enterprise Guide&lt;/LI&gt;
&lt;LI&gt;The Transaction Codes are character variables&lt;/LI&gt;
&lt;LI&gt;Every Transaction Code will&amp;nbsp;include the string "4122"&lt;/LI&gt;
&lt;LI&gt;The string "4122" will only appear once in each Transaction Code&lt;/LI&gt;
&lt;LI&gt;The&amp;nbsp;number of characters&amp;nbsp;on either side of the "4122" string can vary.&amp;nbsp;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;The SCAN Function doesn't&amp;nbsp;seem to work when I tried a multi-character delimiter (It treated 4, 1, &amp;amp; 2 as separate delimiters). If I can use "4122" as delimiter and pull the portion of the Transaction Code to the&amp;nbsp;right of "4122" I can just concatenate "4122" back on the string later on. However, if there is a solution that directly generates the&amp;nbsp;desired output code&amp;nbsp;including "4122" that would be preferred.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;NW&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Feb 2018 22:40:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-Characters-before-a-Specific-String/m-p/440688#M282541</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-02-27T22:40:19Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Characters before a Specific String</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-Characters-before-a-Specific-String/m-p/440697#M282542</link>
      <description>&lt;P&gt;Regular expressions provide an easy method to do this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
length code $40;
input code;
datalines;
601412265320
714122892335
507741225009964
;

data want;
length newCode $40;
set have;
newCode = prxchange("s/.*?(4122.*)/$1/", 1, code);
run;

proc print; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Feb 2018 23:19:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-Characters-before-a-Specific-String/m-p/440697#M282542</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-02-27T23:19:36Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Characters before a Specific String</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-Characters-before-a-Specific-String/m-p/440722#M282543</link>
      <description>&lt;P&gt;Another logic;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;length code $40;&lt;BR /&gt;input code;&lt;BR /&gt;datalines;&lt;BR /&gt;601412265320&lt;BR /&gt;714122892335&lt;BR /&gt;507741225009964&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;data new (drop=i);&lt;BR /&gt;set have;&lt;BR /&gt;Array a{15} _temporary_;&lt;BR /&gt;do i=1 to 12;&lt;BR /&gt;a{i}=substr(code,i,4);&lt;BR /&gt;if a{i}=4122 then do;&lt;BR /&gt;new_var=substr(code,i);&lt;BR /&gt;End;&lt;BR /&gt;End;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc print data=new;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2018 01:43:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-Characters-before-a-Specific-String/m-p/440722#M282543</guid>
      <dc:creator>yashk</dc:creator>
      <dc:date>2018-02-28T01:43:56Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Characters before a Specific String</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-Characters-before-a-Specific-String/m-p/440724#M282544</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/191496"&gt;@yashk&lt;/a&gt;&amp;nbsp;check the log, you're mixing types up here - ie SUBSTR will return a character value, not a numeric and your array is set to be numeric as well.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2018 01:46:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-Characters-before-a-Specific-String/m-p/440724#M282544</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-02-28T01:46:42Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Characters before a Specific String</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-Characters-before-a-Specific-String/m-p/440732#M282545</link>
      <description>&lt;P&gt;Yes. you are correct, thank you for the check.&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: 274px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/18857iBE04E1C088594BF3/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>Wed, 28 Feb 2018 02:05:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-Characters-before-a-Specific-String/m-p/440732#M282545</guid>
      <dc:creator>yashk</dc:creator>
      <dc:date>2018-02-28T02:05:29Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Characters before a Specific String</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-Characters-before-a-Specific-String/m-p/440897#M282546</link>
      <description>&lt;P&gt;This worked perfectly. I don't have much experience with regular expressions though. Will that same PERL regular expression you use in the prxchange function work if the "4122" identifier were a different length? Or would the syntax need to be changed?&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2018 14:34:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-Characters-before-a-Specific-String/m-p/440897#M282546</guid>
      <dc:creator>NW_SAS</dc:creator>
      <dc:date>2018-02-28T14:34:17Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Characters before a Specific String</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-Characters-before-a-Specific-String/m-p/440956#M282547</link>
      <description>&lt;P&gt;You can replace 4122 by any other sequence, as long as it doesn't involve special characters. Special characters would have to be escaped, eg "41.22" would appear in the pattern as "41\.22".&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2018 17:13:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-Characters-before-a-Specific-String/m-p/440956#M282547</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-02-28T17:13:40Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Characters before a Specific String</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-Characters-before-a-Specific-String/m-p/442623#M282548</link>
      <description>&lt;P&gt;Great Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 05 Mar 2018 20:52:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-Characters-before-a-Specific-String/m-p/442623#M282548</guid>
      <dc:creator>NW_SAS</dc:creator>
      <dc:date>2018-03-05T20:52:23Z</dc:date>
    </item>
  </channel>
</rss>

