<?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: extracting a text string from a string in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/extracting-a-text-string-from-a-string/m-p/505129#M135246</link>
    <description>&lt;P&gt;this should work. i have used ?!IDN: ?! is negative lookahead, it will take everything till ; in providername unless IDN comes after providername and&amp;nbsp;I guess this happens when you have no providername&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;re = prxparse('/(ProviderName:\s+(?!IDN:).+?;)/');&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 17 Oct 2018 14:53:56 GMT</pubDate>
    <dc:creator>kiranv_</dc:creator>
    <dc:date>2018-10-17T14:53:56Z</dc:date>
    <item>
      <title>extracting a text string from a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extracting-a-text-string-from-a-string/m-p/504907#M135183</link>
      <description>&lt;P&gt;Hi, I'm trying to extract a text string &lt;SPAN&gt;(name)&amp;nbsp;&lt;/SPAN&gt;from a longer string, which may occur either once within the string or multiple times (several names). I'm breaking the longer string into groups and using prxparse and prxmatch with grouping to extract only the group I need, but something is not working. Below is an example of my text string, my code and what I'm looking for at the end.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data have;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Prov_Info ="ProviderName: Spine and Pain Center of Whatchamikola; IDN: 2345678901; IsGroup: No;,&amp;nbsp; &amp;nbsp;ProviderName: Happy Toes; &lt;SPAN&gt;IDN&lt;/SPAN&gt;: 3456789012; IsGroup: No;,&amp;nbsp; &amp;nbsp;ProviderName:&amp;nbsp; &lt;SPAN&gt;IDN&lt;/SPAN&gt;: 3456789012; IsGroup: Yes;, ProviderName: Bright Smiles of AZ; &lt;SPAN&gt;IDN&lt;/SPAN&gt;: 1234567890 IsGroup: Yes;, ";&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;patternID = prxparse('/^(ProviderName:)( |.*; )(NPI: )/');&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if prxmatch(patternID, strip(Prov_Info)) then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;newname=prxposn(patternID, 2, Prov_Info);&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Result needed:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;newname=&lt;/SPAN&gt;Spine and Pain Center of Whatchamikola; Happy Toes;&amp;nbsp; Bright Smiles of AZ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any suggestions would be attreciated.&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 16 Oct 2018 21:25:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extracting-a-text-string-from-a-string/m-p/504907#M135183</guid>
      <dc:creator>Bluebonnet16</dc:creator>
      <dc:date>2018-10-16T21:25:33Z</dc:date>
    </item>
    <item>
      <title>Re: extracting a text string from a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extracting-a-text-string-from-a-string/m-p/504939#M135198</link>
      <description>&lt;P&gt;you may need to use prxnext.&amp;nbsp;prxparse('/(ProviderName:\s+[a-zA-z ]+?;)/') indicates providers name folowed by space and words and till the ; prxnext capture position and length wherever you have this pattern. by doing substr(prov_info, position+13, length-13, we can remove&amp;nbsp;&lt;SPAN&gt;ProviderName:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have; 
Prov_Info ="ProviderName: Spine and Pain Center of Whatchamikola; 
IDN: 2345678901; IsGroup: No;,
ProviderName: Happy Toes; IDN: 3456789012; IsGroup: No;,
 ProviderName:  IDN: 3456789012; IsGroup: Yes;,
 ProviderName: Bright Smiles of AZ; IDN: 1234567890 IsGroup: Yes;, "; 
  run;
  
 


data want;
length val patternid $200.;
set have;
 start = 1;
   stop = length(prov_info);
 
   re = prxparse('/(ProviderName:\s+[a-zA-z ]+?;)/');
   set have;
   call prxnext(re, start, stop, trim(prov_info), position, length);
      do while (position &amp;gt; 0);
         val = substr(prov_info, position+13, length-13);
          patternID = catx(" ",  patternid, val);
         call prxnext(re, start, stop, trim(prov_info), position, length);
      end;
drop re start stop position length val;
run;

proc print data=want;
run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Oct 2018 00:19:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extracting-a-text-string-from-a-string/m-p/504939#M135198</guid>
      <dc:creator>kiranv_</dc:creator>
      <dc:date>2018-10-17T00:19:24Z</dc:date>
    </item>
    <item>
      <title>Re: extracting a text string from a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extracting-a-text-string-from-a-string/m-p/505069#M135226</link>
      <description>&lt;P&gt;That works! Thank you so very much, kiranv_!!!!&lt;/P&gt;</description>
      <pubDate>Wed, 17 Oct 2018 13:29:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extracting-a-text-string-from-a-string/m-p/505069#M135226</guid>
      <dc:creator>Bluebonnet16</dc:creator>
      <dc:date>2018-10-17T13:29:19Z</dc:date>
    </item>
    <item>
      <title>Re: extracting a text string from a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extracting-a-text-string-from-a-string/m-p/505094#M135232</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;The code works and does exactly what I need. However, I just realized, that if there is a comma in the provider name, a dot, or brackets, then it doesn't. &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Some of the examples, on which the code didn't work:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;data have2;&lt;BR /&gt;&lt;BR /&gt;Prov_Info ="ProviderName: Shapa Inc.;&lt;BR /&gt;&lt;BR /&gt;IDN: 2345678901; IsGroup: No;, ProviderName: Smith, John; IDN: 3456789012; IsGroup: No;,&lt;BR /&gt;&lt;BR /&gt;ProviderName: IDN: 3456789012; IsGroup: Yes;, ProviderName: Pharmacy TX-115; IDN: 1234567890 IsGroup: Yes;, ";&lt;BR /&gt;&lt;BR /&gt;ProviderName: Star Med EMS (Medicare); IDN: 1234567890 IsGroup: Yes;, ";&lt;BR /&gt;&lt;BR /&gt;ProviderName: CVS Pharmacy 50; IDN: 1234567890 IsGroup: Yes;, ";&lt;BR /&gt;&lt;BR /&gt;ProviderName: CASE MANAGEMENT &amp;amp; IDN: 1234567890 IsGroup: Yes;, ";&lt;BR /&gt;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Please let me know if there is a solution to account for those special characters in the provider name? Thank you!&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 17 Oct 2018 13:59:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extracting-a-text-string-from-a-string/m-p/505094#M135232</guid>
      <dc:creator>Bluebonnet16</dc:creator>
      <dc:date>2018-10-17T13:59:17Z</dc:date>
    </item>
    <item>
      <title>Re: extracting a text string from a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extracting-a-text-string-from-a-string/m-p/505112#M135236</link>
      <description>&lt;P&gt;I guess&amp;nbsp;ProviderName: CASE MANAGEMENT &amp;amp; IDN: 1234567890 IsGroup: Yes;, ";&lt;/P&gt;
&lt;P&gt;should be like&amp;nbsp;ProviderName: CASE MANAGEMENT &amp;amp; something; IDN: 1234567890 IsGroup: Yes;, ";&lt;/P&gt;</description>
      <pubDate>Wed, 17 Oct 2018 14:36:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extracting-a-text-string-from-a-string/m-p/505112#M135236</guid>
      <dc:creator>kiranv_</dc:creator>
      <dc:date>2018-10-17T14:36:12Z</dc:date>
    </item>
    <item>
      <title>Re: extracting a text string from a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extracting-a-text-string-from-a-string/m-p/505117#M135239</link>
      <description>Yes, very unusually spelled provider name: ProviderName: MEDICAL CASE MANAGEMENT &amp;amp;amp; SOCIAL SERVICES; IDN: 1234567890; IsGroup: Yes;,&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thank you!&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 17 Oct 2018 14:43:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extracting-a-text-string-from-a-string/m-p/505117#M135239</guid>
      <dc:creator>Bluebonnet16</dc:creator>
      <dc:date>2018-10-17T14:43:17Z</dc:date>
    </item>
    <item>
      <title>Re: extracting a text string from a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extracting-a-text-string-from-a-string/m-p/505123#M135242</link>
      <description>&lt;P&gt;one last question. Do you have numbers in providers name&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;ProviderName: CVS Pharmacy 50&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;if it does not then you can use.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; re = prxparse('/(ProviderName:\s+\D+?;)/');&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 17 Oct 2018 14:46:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extracting-a-text-string-from-a-string/m-p/505123#M135242</guid>
      <dc:creator>kiranv_</dc:creator>
      <dc:date>2018-10-17T14:46:48Z</dc:date>
    </item>
    <item>
      <title>Re: extracting a text string from a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extracting-a-text-string-from-a-string/m-p/505125#M135244</link>
      <description>Yes, unfortunately some provider names, like pharmacies for example, do contain digits in the name&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 17 Oct 2018 14:49:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extracting-a-text-string-from-a-string/m-p/505125#M135244</guid>
      <dc:creator>Bluebonnet16</dc:creator>
      <dc:date>2018-10-17T14:49:17Z</dc:date>
    </item>
    <item>
      <title>Re: extracting a text string from a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extracting-a-text-string-from-a-string/m-p/505129#M135246</link>
      <description>&lt;P&gt;this should work. i have used ?!IDN: ?! is negative lookahead, it will take everything till ; in providername unless IDN comes after providername and&amp;nbsp;I guess this happens when you have no providername&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;re = prxparse('/(ProviderName:\s+(?!IDN:).+?;)/');&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 17 Oct 2018 14:53:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extracting-a-text-string-from-a-string/m-p/505129#M135246</guid>
      <dc:creator>kiranv_</dc:creator>
      <dc:date>2018-10-17T14:53:56Z</dc:date>
    </item>
    <item>
      <title>Re: extracting a text string from a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extracting-a-text-string-from-a-string/m-p/505132#M135247</link>
      <description>Yeap, it worked!! No missing values for the patternID &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thank you So SO SO very much!!!!&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 17 Oct 2018 14:58:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extracting-a-text-string-from-a-string/m-p/505132#M135247</guid>
      <dc:creator>Bluebonnet16</dc:creator>
      <dc:date>2018-10-17T14:58:17Z</dc:date>
    </item>
    <item>
      <title>Re: extracting a text string from a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extracting-a-text-string-from-a-string/m-p/505133#M135248</link>
      <description>&lt;P&gt;You are welcome and I am glad it worked&lt;/P&gt;</description>
      <pubDate>Wed, 17 Oct 2018 14:59:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extracting-a-text-string-from-a-string/m-p/505133#M135248</guid>
      <dc:creator>kiranv_</dc:creator>
      <dc:date>2018-10-17T14:59:42Z</dc:date>
    </item>
  </channel>
</rss>

