<?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 string from word in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Extract-string-from-word/m-p/272352#M54173</link>
    <description>&lt;P&gt;This will work for simple queries (e.g. no subqueries)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data queries;
length query $200;
infile datalines truncover;
input query $char100.;
datalines4;
Proc SQL; create table t1 as select a from b, c,d; quit;
Proc SQL; create table t2 as select a from t3 inner join t4 on t3.id=t4.Id ; quit;
Proc SQL; create table t5 as select a from t6 left join t7 on t6.id=t8.id left join t8 on t6.id=t8.id; quit;
;;;;

data want;
length tbl $64 tbls $200;
if not prx1 then prx1 + prxparse("/\bfrom\s+(\w+)((?:\s*,\s*(?:\w+))*)\b|\bjoin\s+(\w+)\b/i");
set queries;
start=1; stop = -1;
call prxnext(prx1, start, stop, query, pos, len);
do while(pos &amp;gt; 0);
    tbl = catx(",", 
        cats(   prxposn(prx1, 1, query), 
                compress(prxposn(prx1, 2, query))), 
        prxposn(prx1, 3, query));
    tbls = catx(",", tbls, tbl);
    call prxnext(prx1, start, stop, query, pos, len);
    end;
drop prx1 tbl start stop pos len;
run;

proc print data=want; var tbls;  run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 23 May 2016 03:11:30 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2016-05-23T03:11:30Z</dc:date>
    <item>
      <title>Extract string from word</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-string-from-word/m-p/272338#M54170</link>
      <description>Hi there,&lt;BR /&gt;&lt;BR /&gt;I need to extract part of string. Actually my proc SQL code is saved in string and I need to find source table from it.&lt;BR /&gt;&lt;BR /&gt;Below is my input &lt;BR /&gt;&lt;BR /&gt;Code &lt;BR /&gt;Proc SQL; create table t1 as select a from b,c; quit;&lt;BR /&gt;Proc SQL; create table t2 as select a from t3 inner join t4 on t3.id=t4.Id ; quit;&lt;BR /&gt;Proc SQL; create table t5 as select a from t6 left join t7 on t6.id=t8.id; quit;&lt;BR /&gt;&lt;BR /&gt;Output needed as below:&lt;BR /&gt;Source &lt;BR /&gt;B,c&lt;BR /&gt;T3,t4&lt;BR /&gt;T6,t8&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Any help is really appreciated</description>
      <pubDate>Mon, 23 May 2016 00:36:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-string-from-word/m-p/272338#M54170</guid>
      <dc:creator>yashpande</dc:creator>
      <dc:date>2016-05-23T00:36:19Z</dc:date>
    </item>
    <item>
      <title>Re: Extract string from word</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-string-from-word/m-p/272340#M54171</link>
      <description>&lt;P&gt;Find the words after FROM/JOIN&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 May 2016 00:55:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-string-from-word/m-p/272340#M54171</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-05-23T00:55:17Z</dc:date>
    </item>
    <item>
      <title>Re: Extract string from word</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-string-from-word/m-p/272349#M54172</link>
      <description>Yes that's right.</description>
      <pubDate>Mon, 23 May 2016 02:38:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-string-from-word/m-p/272349#M54172</guid>
      <dc:creator>yashpande</dc:creator>
      <dc:date>2016-05-23T02:38:01Z</dc:date>
    </item>
    <item>
      <title>Re: Extract string from word</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-string-from-word/m-p/272352#M54173</link>
      <description>&lt;P&gt;This will work for simple queries (e.g. no subqueries)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data queries;
length query $200;
infile datalines truncover;
input query $char100.;
datalines4;
Proc SQL; create table t1 as select a from b, c,d; quit;
Proc SQL; create table t2 as select a from t3 inner join t4 on t3.id=t4.Id ; quit;
Proc SQL; create table t5 as select a from t6 left join t7 on t6.id=t8.id left join t8 on t6.id=t8.id; quit;
;;;;

data want;
length tbl $64 tbls $200;
if not prx1 then prx1 + prxparse("/\bfrom\s+(\w+)((?:\s*,\s*(?:\w+))*)\b|\bjoin\s+(\w+)\b/i");
set queries;
start=1; stop = -1;
call prxnext(prx1, start, stop, query, pos, len);
do while(pos &amp;gt; 0);
    tbl = catx(",", 
        cats(   prxposn(prx1, 1, query), 
                compress(prxposn(prx1, 2, query))), 
        prxposn(prx1, 3, query));
    tbls = catx(",", tbls, tbl);
    call prxnext(prx1, start, stop, query, pos, len);
    end;
drop prx1 tbl start stop pos len;
run;

proc print data=want; var tbls;  run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 23 May 2016 03:11:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-string-from-word/m-p/272352#M54173</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-05-23T03:11:30Z</dc:date>
    </item>
  </channel>
</rss>

