<?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: SAS prxparse Function in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-prxparse-Function/m-p/377020#M276680</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile cards truncover ;
input have_str $500.;
cards;
Firm A advises on the Volkswagen settlement with US authorities regarding emissions from diesel engines Firm A advises The Carlyle Group on its $3.2bn acquisition of Atotech advising Coca Cola
;
run;

data want;
 set have;
 temp=have_str;
 p=prxmatch('/\b(advises|advised|advising)\b/i',temp);

 do while(p);
  temp=substr(temp,p);
  temp=substr(temp,findc(temp,' ')+1);
  name=catx(' ',scan(temp,1,' '),scan(temp,2,' '),scan(temp,3,' '));
  output;
  p=prxmatch('/\b(advises|advised|advising)\b/i',temp);
 end;

 drop temp p;
 run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 18 Jul 2017 14:22:30 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2017-07-18T14:22:30Z</dc:date>
    <item>
      <title>SAS prxparse Function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-prxparse-Function/m-p/377005#M276678</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am wanting to seperate out client names from a lengthy bit of text based on keywords that they come after. The code that I have been using in dev is below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;infile cards truncover;&lt;BR /&gt;input have_str $500.;&lt;BR /&gt;cards;&lt;BR /&gt;Firm A advises on the Volkswagen settlement with US authorities regarding emissions from diesel engines Firm A advises The Carlyle Group on its $3.2bn acquisition of Atotech advising Coca Cola&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data want;&lt;BR /&gt;set have;&lt;BR /&gt;retain _prxid;&lt;/P&gt;&lt;P&gt;/*advised*/&lt;BR /&gt;if _n_=1 then&lt;BR /&gt;_prxid=prxparse('/(\badvised)[^A-Z]{0,10}(([A-Z]\w+\s*\b)+)/');&lt;BR /&gt;if prxmatch(_prxid, have_str) then do;&lt;BR /&gt;client1=prxposn(_prxid, 2, have_str);&lt;BR /&gt;end;;&lt;/P&gt;&lt;P&gt;/*advises*/&lt;BR /&gt;if _n_=1 then&lt;BR /&gt;_prxid=prxparse('/(\badvises)[^A-Z]{0,10}(([A-Z]\w+\s*\b)+)/');&lt;BR /&gt;if prxmatch(_prxid, have_str) then do;&lt;BR /&gt;client2=prxposn(_prxid, 2, have_str);&lt;BR /&gt;end;;&lt;/P&gt;&lt;P&gt;/*advising*/&lt;BR /&gt;if _n_=1 then&lt;BR /&gt;_prxid=prxparse('/(\badvising)[^A-Z]{0,10}(([A-Z]\w+\s*\b)+)/');&lt;BR /&gt;if prxmatch(_prxid, have_str) then do;&lt;BR /&gt;client3=prxposn(_prxid, 2, have_str);&lt;BR /&gt;end;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are multiple keywords such as "advising" or "advised" that I'm interested in. When the same keyword "advises" appears more than once in the same sentence then the data isn't populated. Any ideas please?&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jul 2017 13:53:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-prxparse-Function/m-p/377005#M276678</guid>
      <dc:creator>cmoore</dc:creator>
      <dc:date>2017-07-18T13:53:21Z</dc:date>
    </item>
    <item>
      <title>Re: SAS prxparse Function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-prxparse-Function/m-p/377007#M276679</link>
      <description>&lt;P&gt;The 3 outputs I want are; Client1=Volkswaggen, Client2=The Caryle Group and Client3=Coca Cola&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jul 2017 13:57:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-prxparse-Function/m-p/377007#M276679</guid>
      <dc:creator>cmoore</dc:creator>
      <dc:date>2017-07-18T13:57:53Z</dc:date>
    </item>
    <item>
      <title>Re: SAS prxparse Function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-prxparse-Function/m-p/377020#M276680</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile cards truncover ;
input have_str $500.;
cards;
Firm A advises on the Volkswagen settlement with US authorities regarding emissions from diesel engines Firm A advises The Carlyle Group on its $3.2bn acquisition of Atotech advising Coca Cola
;
run;

data want;
 set have;
 temp=have_str;
 p=prxmatch('/\b(advises|advised|advising)\b/i',temp);

 do while(p);
  temp=substr(temp,p);
  temp=substr(temp,findc(temp,' ')+1);
  name=catx(' ',scan(temp,1,' '),scan(temp,2,' '),scan(temp,3,' '));
  output;
  p=prxmatch('/\b(advises|advised|advising)\b/i',temp);
 end;

 drop temp p;
 run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 18 Jul 2017 14:22:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-prxparse-Function/m-p/377020#M276680</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-07-18T14:22:30Z</dc:date>
    </item>
    <item>
      <title>Re: SAS prxparse Function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-prxparse-Function/m-p/377378#M276681</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename ft15f001 temp;
data have;
infile ft15f001;
input text $194.;
parmcards;
firm a advises on the volkswagen settlement with us authorities regarding  emissions from diesel engines firm a advises the carlyle group on its  $3.2bn acquisition of atotech advising coca cola
;
run;

data want;
	prxid=prxparse('/\badvis(?:es|ed|ing)\b\s+((\b\w+\b\s*){1,3})/i');
	do until (eof);
		set have end=eof;
		start=1;
		stop=length(text);
		call prxnext(prxid, start, stop, text, position, length);
		do while (position &amp;gt; 0);
			call prxposn(prxid, 1, start, length);
			match=substr(text, start, length);
			output;
			call prxnext(prxid, start, stop, text, position, length);
		end;
	end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Jul 2017 15:09:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-prxparse-Function/m-p/377378#M276681</guid>
      <dc:creator>FriedEgg</dc:creator>
      <dc:date>2017-07-19T15:09:32Z</dc:date>
    </item>
    <item>
      <title>Re: SAS prxparse Function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-prxparse-Function/m-p/377662#M276682</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the solutions &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;you have sent me they are very useful. Just a final question in this area. In some data cells I have the following raw data:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"Deutsche Bank, Bank of America, Merrill Lynch and Morgan Stanley on National Grid's £3.3 billion equity offering"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;They have no keywords associated with them such as 'advised' like the example. I am wanting to pull out of the data '&lt;SPAN&gt;Deutsche Bank', 'Bank of America', 'Merrill Lynch' and 'Morgan Stanley' in exactly the same way as your solution. I'm not interested in obtaining 'National Grid'. Basically a firm has worked with&amp;nbsp;the 4 firms I have highlighted but not National Grid. Are there any rules I can apply for any such scenarios that may come up in my data?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks for all your help.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;Chris&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2017 07:29:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-prxparse-Function/m-p/377662#M276682</guid>
      <dc:creator>cmoore</dc:creator>
      <dc:date>2017-07-20T07:29:41Z</dc:date>
    </item>
    <item>
      <title>Re: SAS prxparse Function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-prxparse-Function/m-p/377664#M276683</link>
      <description>&lt;P&gt;Or where the keywords such as 'Advised' etc don't exist take start of sentence to the words "on" to isolate the clients I'm interested in. That's what I'm trying to embed into the current syntax you sent me&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2017 07:36:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-prxparse-Function/m-p/377664#M276683</guid>
      <dc:creator>cmoore</dc:creator>
      <dc:date>2017-07-20T07:36:05Z</dc:date>
    </item>
    <item>
      <title>Re: SAS prxparse Function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-prxparse-Function/m-p/377730#M276684</link>
      <description>&lt;P&gt;OK. I don't know if the following could work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;

data have;
infile cards truncover ;
input have_str $500.;
cards;
Firm A advises on the Volkswagen settlement with US authorities regarding emissions from diesel engines Firm A advises The Carlyle Group on its $3.2bn acquisition of Atotech advising Coca Cola
Deutsche Bank, Bank of America, Merrill Lynch and Morgan Stanley on National Grid's £3.3 billion equity offering
;
run;

data want;
 set have;
 temp=have_str;
 p=prxmatch('/\b(advises|advised|advising)\b/i',temp);
if p=0 then do;
   name=substr(temp,1,prxmatch('/\bon\b/i',temp)-1);
   output;
end;
else do;
 do while(p);
  temp=substr(temp,p);
  temp=substr(temp,findc(temp,' ')+1);
  name=catx(' ',scan(temp,1,' '),scan(temp,2,' '),scan(temp,3,' '));
  output;
  p=prxmatch('/\b(advises|advised|advising)\b/i',temp);
 end;
end;
 drop temp p;
 run;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 20 Jul 2017 12:51:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-prxparse-Function/m-p/377730#M276684</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-07-20T12:51:34Z</dc:date>
    </item>
  </channel>
</rss>

