<?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: extract une substring inside a string with separator in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/extract-une-substring-inside-a-string-with-separator/m-p/654285#M196516</link>
    <description>The perl regular expression works on the basis of meta characters which recognizes the patterns like digits, letters, special characters, so here we are using the &lt;BR /&gt;&lt;BR /&gt;dot which means any character including the special character &lt;BR /&gt; * which means recognize the any character including the special character any number of times&lt;BR /&gt;sbsas is the word with which you want to end the pattern&lt;BR /&gt;() is group, to recognize a particular group pattern&lt;BR /&gt;so here we have 3 groups &lt;BR /&gt;s/ - substitution &lt;BR /&gt;$2 - keep the second group&lt;BR /&gt;-1 - recognize the pattern as it occurs 1 or more &lt;BR /&gt;o- retain the pattern to all records&lt;BR /&gt;i - ignore case &lt;BR /&gt;</description>
    <pubDate>Mon, 08 Jun 2020 08:06:01 GMT</pubDate>
    <dc:creator>Jagadishkatam</dc:creator>
    <dc:date>2020-06-08T08:06:01Z</dc:date>
    <item>
      <title>extract une substring inside a string with separator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extract-une-substring-inside-a-string-with-separator/m-p/653670#M196339</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I get pathnames in a macro variable and I would like to extract the string between the 4th folder and the program name&lt;/P&gt;
&lt;P&gt;exemple1, '/data/crea/creapil/sbsas/SUIVIS/ACCEPTATION/SUI_Q_DOS_PAI.sas' the result should be /SUIVIS/ACCEPTATION/&lt;/P&gt;
&lt;P&gt;example 2 '/data/crea/creapil/sbsas/SUIVIS/CLIENT/RECOUV/CESSION/SUI_Q_CESSION.sas' the result should be SUIVIS/CLIENT/RECOUV/CESSION/&lt;/P&gt;
&lt;P&gt;thanks in advance for your help&lt;/P&gt;
&lt;P&gt;regards&lt;/P&gt;
&lt;P&gt;Nas&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jun 2020 15:30:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extract-une-substring-inside-a-string-with-separator/m-p/653670#M196339</guid>
      <dc:creator>Nasser_DRMCP</dc:creator>
      <dc:date>2020-06-05T15:30:04Z</dc:date>
    </item>
    <item>
      <title>Re: extract une substring inside a string with separator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extract-une-substring-inside-a-string-with-separator/m-p/653680#M196343</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/147725"&gt;@Nasser_DRMCP&lt;/a&gt;&amp;nbsp; What you need is CALL SCAN&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
length str $200;
str= '/data/crea/creapil/sbsas/SUIVIS/ACCEPTATION/SUI_Q_DOS_PAI.sas' ;
output;
str='/data/crea/creapil/sbsas/SUIVIS/CLIENT/RECOUV/CESSION/SUI_Q_CESSION.sas';
output;
run;

data want;
 set have;
 call scan(str, 5, _p, _l,'/');
 call scan(str, -1, _p1, _l1,'/');
 need=substr(str,_p-1,_p1+1-_p);
 drop _:;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 05 Jun 2020 15:44:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extract-une-substring-inside-a-string-with-separator/m-p/653680#M196343</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-06-05T15:44:25Z</dc:date>
    </item>
    <item>
      <title>Re: extract une substring inside a string with separator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extract-une-substring-inside-a-string-with-separator/m-p/653715#M196345</link>
      <description>thanks for your quick respons.&lt;BR /&gt;could you please explain call scan(str, 5, _p, _l,'/'); ?</description>
      <pubDate>Fri, 05 Jun 2020 15:55:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extract-une-substring-inside-a-string-with-separator/m-p/653715#M196345</guid>
      <dc:creator>Nasser_DRMCP</dc:creator>
      <dc:date>2020-06-05T15:55:05Z</dc:date>
    </item>
    <item>
      <title>Re: extract une substring inside a string with separator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extract-une-substring-inside-a-string-with-separator/m-p/653716#M196346</link>
      <description>&lt;P&gt;Novin's solution is good as long as you know what position to start the data from. I learnt something new today. Call Scan function, did not use it.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jun 2020 15:56:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extract-une-substring-inside-a-string-with-separator/m-p/653716#M196346</guid>
      <dc:creator>smantha</dc:creator>
      <dc:date>2020-06-05T15:56:12Z</dc:date>
    </item>
    <item>
      <title>Re: extract une substring inside a string with separator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extract-une-substring-inside-a-string-with-separator/m-p/653727#M196347</link>
      <description>&lt;P&gt;&lt;SPAN&gt;could you please explain call scan(str, 5, _p, _l,'/'); ?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Basically you mentioned in your original post &lt;EM&gt;"&amp;nbsp;I would like to extract the string between the 4th folder and the program name".&amp;nbsp;&lt;/EM&gt;This is the starting point to think through the logic. Given the start being obvious i.e. we begin from the position right after the 4th folder and that is 5th substr separated by '/'.&amp;nbsp; We evaluate the position of the start of the 5th folder including from the point at which delimiter '/' begins. This is part 1.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Secondly we evaluate the end of the beginning&amp;nbsp;of the program name using the 2nd call scan to exclude those characters. So the difference between starting position of program name and ending position of 4th folder is what we do using call scan.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Finally, we extract the substring of chars using the length value evaluated&amp;nbsp;above starting from the ending position of the 4th folder. Hope this helps?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jun 2020 16:10:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extract-une-substring-inside-a-string-with-separator/m-p/653727#M196347</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-06-05T16:10:09Z</dc:date>
    </item>
    <item>
      <title>Re: extract une substring inside a string with separator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extract-une-substring-inside-a-string-with-separator/m-p/653729#M196348</link>
      <description>&lt;P&gt;Alternatively with perl regular expression you can try below code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
 set have;
 need=prxchange('s/(.*sbsas)(.*)(sui_q.*)/$2/oi',-1,str);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 05 Jun 2020 16:23:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extract-une-substring-inside-a-string-with-separator/m-p/653729#M196348</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2020-06-05T16:23:49Z</dc:date>
    </item>
    <item>
      <title>Re: extract une substring inside a string with separator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extract-une-substring-inside-a-string-with-separator/m-p/654244#M196514</link>
      <description>Thanks for your help and your reactivity</description>
      <pubDate>Mon, 08 Jun 2020 07:42:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extract-une-substring-inside-a-string-with-separator/m-p/654244#M196514</guid>
      <dc:creator>Nasser_DRMCP</dc:creator>
      <dc:date>2020-06-08T07:42:24Z</dc:date>
    </item>
    <item>
      <title>Re: extract une substring inside a string with separator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extract-une-substring-inside-a-string-with-separator/m-p/654260#M196515</link>
      <description>Thanks Jagadishkatam . could you please explain ? thanks in advance&lt;BR /&gt;</description>
      <pubDate>Mon, 08 Jun 2020 07:55:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extract-une-substring-inside-a-string-with-separator/m-p/654260#M196515</guid>
      <dc:creator>Nasser_DRMCP</dc:creator>
      <dc:date>2020-06-08T07:55:08Z</dc:date>
    </item>
    <item>
      <title>Re: extract une substring inside a string with separator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extract-une-substring-inside-a-string-with-separator/m-p/654285#M196516</link>
      <description>The perl regular expression works on the basis of meta characters which recognizes the patterns like digits, letters, special characters, so here we are using the &lt;BR /&gt;&lt;BR /&gt;dot which means any character including the special character &lt;BR /&gt; * which means recognize the any character including the special character any number of times&lt;BR /&gt;sbsas is the word with which you want to end the pattern&lt;BR /&gt;() is group, to recognize a particular group pattern&lt;BR /&gt;so here we have 3 groups &lt;BR /&gt;s/ - substitution &lt;BR /&gt;$2 - keep the second group&lt;BR /&gt;-1 - recognize the pattern as it occurs 1 or more &lt;BR /&gt;o- retain the pattern to all records&lt;BR /&gt;i - ignore case &lt;BR /&gt;</description>
      <pubDate>Mon, 08 Jun 2020 08:06:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extract-une-substring-inside-a-string-with-separator/m-p/654285#M196516</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2020-06-08T08:06:01Z</dc:date>
    </item>
    <item>
      <title>Re: extract une substring inside a string with separator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extract-une-substring-inside-a-string-with-separator/m-p/654324#M196517</link>
      <description>&lt;P&gt;&lt;EM&gt;Thanks&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;I am sorry , but the file name do not always begin with "&lt;/EM&gt;SUI_Q" it was just examples. it could be INC_ or MON_ or...&lt;/P&gt;
&lt;P&gt;sorry, I forgot to specify it.&lt;/P&gt;
&lt;P&gt;and is it possible to use this command into a macro variable ?&lt;/P&gt;
&lt;P&gt;thanks&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jun 2020 08:29:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extract-une-substring-inside-a-string-with-separator/m-p/654324#M196517</guid>
      <dc:creator>Nasser_DRMCP</dc:creator>
      <dc:date>2020-06-08T08:29:30Z</dc:date>
    </item>
    <item>
      <title>Re: extract une substring inside a string with separator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extract-une-substring-inside-a-string-with-separator/m-p/654386#M196518</link>
      <description>&lt;P&gt;in that case please try the below code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data want;
 set have;
 need=prxchange('s/(.*sbsas)(.*\/)(.*sas)/$2/oi',-1,str);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 08 Jun 2020 09:12:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extract-une-substring-inside-a-string-with-separator/m-p/654386#M196518</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2020-06-08T09:12:37Z</dc:date>
    </item>
    <item>
      <title>Re: extract une substring inside a string with separator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extract-une-substring-inside-a-string-with-separator/m-p/654387#M196519</link>
      <description>Could you please let me know how you want to use it in a macro variable, so i can help you</description>
      <pubDate>Mon, 08 Jun 2020 09:15:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extract-une-substring-inside-a-string-with-separator/m-p/654387#M196519</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2020-06-08T09:15:51Z</dc:date>
    </item>
    <item>
      <title>Re: extract une substring inside a string with separator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extract-une-substring-inside-a-string-with-separator/m-p/654473#M196529</link>
      <description>&lt;P&gt;sorry, in fact I can get the result in a macro variable by using &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;call&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; symput.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Sorry but there is someting left I don t understand.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;why, the second group should be &lt;/FONT&gt;(.*\/)&amp;nbsp; to obtain /SUIVIS/ACCEPTATION/&lt;/P&gt;
&lt;P&gt;many thanks&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jun 2020 11:34:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extract-une-substring-inside-a-string-with-separator/m-p/654473#M196529</guid>
      <dc:creator>Nasser_DRMCP</dc:creator>
      <dc:date>2020-06-08T11:34:43Z</dc:date>
    </item>
  </channel>
</rss>

