<?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: how to PRXPARSE this substring in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/how-to-PRXPARSE-this-substring/m-p/257855#M57301</link>
    <description>&lt;P&gt;Can you provide a few test strings that cover the range of your input text: things that should match and strings that shouldn't?&lt;/P&gt;</description>
    <pubDate>Sun, 20 Mar 2016 18:07:58 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2016-03-20T18:07:58Z</dc:date>
    <item>
      <title>how to PRXPARSE this substring</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-PRXPARSE-this-substring/m-p/257841#M57297</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to use PRXPARSE function to get sub strings like these:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;'10-30 oz' or '25 lb' &amp;nbsp; or '2.5&amp;nbsp; -&amp;nbsp; 55 lbs' ,..... ect&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I use this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PATTERN =PRXPARSE("/(\d+\.*\d+ *-* *\d+\.*\d+ *)|(\d+\.?\d+-\d+\.?\d+ (lb|oz))|(\d+\.?\d+\.?\d+ (lb|oz))|(\d+\.?\d+? (lb|oz))|(\d+? *(lb|oz))|(\d *- *\d *(lb|oz))|(\d+?.\d+? *(lb|oz))|(\d+.\d+ *- *\d *(lb|oz))|(\d *- *\d+.\d+ *(lb|oz))/");&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but this is not good.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;please help,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;thanks&lt;/P&gt;</description>
      <pubDate>Sun, 20 Mar 2016 15:57:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-PRXPARSE-this-substring/m-p/257841#M57297</guid>
      <dc:creator>GeorgeSAS</dc:creator>
      <dc:date>2016-03-20T15:57:51Z</dc:date>
    </item>
    <item>
      <title>Re: how to PRXPARSE this substring</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-PRXPARSE-this-substring/m-p/257854#M57300</link>
      <description>&lt;P&gt;We need to know what your full text looks like. Also, what issues are occurring in with your current code.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 20 Mar 2016 18:05:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-PRXPARSE-this-substring/m-p/257854#M57300</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-03-20T18:05:42Z</dc:date>
    </item>
    <item>
      <title>Re: how to PRXPARSE this substring</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-PRXPARSE-this-substring/m-p/257855#M57301</link>
      <description>&lt;P&gt;Can you provide a few test strings that cover the range of your input text: things that should match and strings that shouldn't?&lt;/P&gt;</description>
      <pubDate>Sun, 20 Mar 2016 18:07:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-PRXPARSE-this-substring/m-p/257855#M57301</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-03-20T18:07:58Z</dc:date>
    </item>
    <item>
      <title>Re: how to PRXPARSE this substring</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-PRXPARSE-this-substring/m-p/257867#M57302</link>
      <description>&lt;P&gt;Maybe this is good :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;"/\d+(\.\d*)?\s{0,2}(-\s{0,2}\d+(\.\d*)?)?\s?(lbs|lb|oz)/i"&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;(not tested much)&lt;/P&gt;</description>
      <pubDate>Sun, 20 Mar 2016 20:05:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-PRXPARSE-this-substring/m-p/257867#M57302</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-03-20T20:05:41Z</dc:date>
    </item>
    <item>
      <title>Re: how to PRXPARSE this substring</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-PRXPARSE-this-substring/m-p/257891#M57308</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
length x $ 100;
x='10-30 oz';output;
x='25 lb';output;  
x='2.5  -  55 lbs';output;
run;
data _null_;
 set have;
 if prxmatch('/([\s\d\.]+\-)?[\s\d\.]+(oz|lb|lbs)/i',x) then putlog 'Matched';
  else putlog 'Not Matched';
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 21 Mar 2016 01:21:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-PRXPARSE-this-substring/m-p/257891#M57308</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-03-21T01:21:57Z</dc:date>
    </item>
    <item>
      <title>Re: how to PRXPARSE this substring</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-PRXPARSE-this-substring/m-p/257904#M57316</link>
      <description>&lt;P&gt;Xia, please note that you must name the longer alternatives first, (oz|lbs|lb) for example, because the parser stops at the first match, so that&amp;nbsp;&lt;SPAN&gt;(oz|lb|lbs) will never match the s in lbs.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Mar 2016 03:04:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-PRXPARSE-this-substring/m-p/257904#M57316</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-03-21T03:04:50Z</dc:date>
    </item>
    <item>
      <title>Re: how to PRXPARSE this substring</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-PRXPARSE-this-substring/m-p/257905#M57317</link>
      <description>&lt;P&gt;A comparison&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
length str $64;
do str = 
    "The Wizard of Oz says",
    "There are 10-30 oz of potatoes",
    "or 25 lb of onions",
    "and 2.5  -  55 lbs of lard in this delicious recipe.";
    output;
    end;
run;

data amtPG;
length subStr $20;
if not prx1 then prx1 + 
    prxparse("/\d+(\.\d*)?\s{0,2}(-\s{0,2}\d+(\.\d*)?)?\s?(lbs|lb|oz)/i");
set test;
if prxmatch(prx1, str) then do;
    subStr = prxposn(prx1, 0, str);
    output;
    end;
drop prx1;
run;

title "PG's pattern";
proc print data=amtPG noobs; run;

data amtXK;
length subStr $20;
if not prx1 then prx1 + 
    prxparse('/([\s\d\.]+\-)?[\s\d\.]+(oz|lb|lbs)/i');
set test;
if prxmatch(prx1, str) then do;
    subStr = prxposn(prx1, 0, str);
    output;
    end;
drop prx1;
run;

title "XK's pattern";
proc print data=amtXk noobs; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;                                    PG's pattern    

       subStr            str

       10-30 oz          There are 10-30 oz of potatoes
       25 lb             or 25 lb of onions
       2.5  -  55 lbs    and 2.5  -  55 lbs of lard in this delicious recipe.
&amp;#12;
                                    XK's pattern    

       subStr           str

       Oz               The Wizard of Oz says
       10-30 oz         There are 10-30 oz of potatoes
       25 lb            or 25 lb of onions
       2.5  -  55 lb    and 2.5  -  55 lbs of lard in this delicious recipe.
&lt;/PRE&gt;</description>
      <pubDate>Mon, 21 Mar 2016 03:20:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-PRXPARSE-this-substring/m-p/257905#M57317</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-03-21T03:20:23Z</dc:date>
    </item>
  </channel>
</rss>

