<?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: Functions to subtract knowing a keyword in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Functions-to-subtract-knowing-a-keyword/m-p/639540#M190289</link>
    <description>&lt;P&gt;Get possibly multiple matches per string with prxNext:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
if not prxId then prxId + prxParse("/LIB\.\w+\.\w+/");
set have;
start = 1; stop = length(text);
call prxnext(prxID, start, stop, text, position, length);
  do while (position &amp;gt; 0);
     word = substr(text, position, length);
     output;
     call prxnext(prxID, start, stop, text, position, length);
  end;
drop start stop position length;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Add &lt;STRONG&gt;if position=0 then output;&lt;/STRONG&gt; after the first call to prxNext if you want some output for empty matches.&lt;/P&gt;</description>
    <pubDate>Mon, 13 Apr 2020 18:24:37 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2020-04-13T18:24:37Z</dc:date>
    <item>
      <title>Functions to subtract knowing a keyword</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Functions-to-subtract-knowing-a-keyword/m-p/639442#M190251</link>
      <description>&lt;P&gt;Dear community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to subtract a specific group of words separated by dot.&lt;/P&gt;&lt;P&gt;The first word will always be LIB followed by a dataset name and a variable name. However, in the same description LIB can be present multiple times, but only once will have both dataset and variable name attached.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried using PRX functions but without success.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
length text $200;
infile datalines dsd;
input text;
datalines;
Random text LIB.XX_YYY.ZZZZZZZZ random text LIB.XX_YYY random text.
Random text LIB.AA random text LIB.AA.BB_BBB
LIB.XX3_X.YZYZYZ3
Random text LIB.AA1: random text LIB.AA1.ABCD, random text LIB. 
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;So from the above dataset I would like to keep in a variable: 'LIB.XX_YYY.ZZZZZZZZ' for first row, 'LIB.AA.BB_BBB' for the second row etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Apr 2020 12:42:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Functions-to-subtract-knowing-a-keyword/m-p/639442#M190251</guid>
      <dc:creator>mozty</dc:creator>
      <dc:date>2020-04-13T12:42:50Z</dc:date>
    </item>
    <item>
      <title>Re: Functions to subtract knowing a keyword</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Functions-to-subtract-knowing-a-keyword/m-p/639494#M190265</link>
      <description>&lt;P&gt;Please show what the exact desired output for the given data would be.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And you should provide a general rule. We cannot tell what the "etc" results would be because there is no general rule to apply.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Apr 2020 15:28:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Functions-to-subtract-knowing-a-keyword/m-p/639494#M190265</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-04-13T15:28:14Z</dc:date>
    </item>
    <item>
      <title>Re: Functions to subtract knowing a keyword</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Functions-to-subtract-knowing-a-keyword/m-p/639505#M190272</link>
      <description>&lt;P&gt;The general rule is on each row to locate and keep in a new variable only the group of 3 words starting with LIB and having '.' as separator.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My desired output is:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;keep&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;PRE class="language-sas"&gt;&lt;CODE&gt;LIB.XX_YYY.ZZZZZZZZ&lt;/CODE&gt;&lt;/PRE&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;PRE class="language-sas"&gt;&lt;CODE&gt;LIB.AA.BB_BBB&lt;/CODE&gt;&lt;/PRE&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;PRE class="language-sas"&gt;&lt;CODE&gt;LIB.XX3_X.YZYZYZ3&lt;/CODE&gt;&lt;/PRE&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;PRE class="language-sas"&gt;&lt;CODE&gt;LIB.AA1.ABCD&lt;/CODE&gt;&lt;/PRE&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Mon, 13 Apr 2020 15:52:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Functions-to-subtract-knowing-a-keyword/m-p/639505#M190272</guid>
      <dc:creator>mozty</dc:creator>
      <dc:date>2020-04-13T15:52:29Z</dc:date>
    </item>
    <item>
      <title>Re: Functions to subtract knowing a keyword</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Functions-to-subtract-knowing-a-keyword/m-p/639540#M190289</link>
      <description>&lt;P&gt;Get possibly multiple matches per string with prxNext:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
if not prxId then prxId + prxParse("/LIB\.\w+\.\w+/");
set have;
start = 1; stop = length(text);
call prxnext(prxID, start, stop, text, position, length);
  do while (position &amp;gt; 0);
     word = substr(text, position, length);
     output;
     call prxnext(prxID, start, stop, text, position, length);
  end;
drop start stop position length;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Add &lt;STRONG&gt;if position=0 then output;&lt;/STRONG&gt; after the first call to prxNext if you want some output for empty matches.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Apr 2020 18:24:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Functions-to-subtract-knowing-a-keyword/m-p/639540#M190289</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2020-04-13T18:24:37Z</dc:date>
    </item>
  </channel>
</rss>

