<?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: Help with PERL string count for address var in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Help-with-PERL-string-count-for-address-var/m-p/452473#M283840</link>
    <description>hi Ksharp... it is 1 in my example (although a zero could work, but should never be 2,or 3). I've struggled in perl with making count of example (ii) identical to count of (i) (and that is related to how /b function operates i believe</description>
    <pubDate>Mon, 09 Apr 2018 11:53:28 GMT</pubDate>
    <dc:creator>brulard</dc:creator>
    <dc:date>2018-04-09T11:53:28Z</dc:date>
    <item>
      <title>Help with PERL string count for address var</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-PERL-string-count-for-address-var/m-p/451890#M283837</link>
      <description>&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;i'm looking to count how many words contain 1 or more numeric characters (for address variable).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following&amp;nbsp;code almost does it: prxparse('/&lt;STRONG&gt;\d{1}\b&lt;/STRONG&gt;/'), derived from a very useful suggestion from Ksharp in prior post.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But it needs another enhancement: in example below, all&amp;nbsp;words are properly counted, &lt;STRONG&gt;Except record (i)&lt;/STRONG&gt; [which should be 3], where note the&amp;nbsp;101A in (i) is reverse of&amp;nbsp;A101 in (ii).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input;
have=_infile_;
pid=prxparse('/\d{1}\b/');
s=1;e=length(_infile_);
n=0;
call prxnext(pid,s,e,_infile_,p,l);
do while(p&amp;gt;0);
 n+1;
 call prxnext(pid,s,e,_infile_,p,l);
end;
keep have n;
cards;
()  189 ELIOT STREET | UNIT 112 | ROCKLAND | ON | K4K0G4 | CAN
(i)  1769 101A AVE | SURREY | BC | V4N5V8 | CAN
(ii) 1769 A101 AVE | SURREY | BC | V4N5V8 | CAN
(iii) 204 ALGONQUIN RD UNIT114 
(iv) BUREAU N2P1G1  106
(v) 29-549 RGE RD 232  STURGEON COUNTY  AB  T8L5E9  CAN
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A word boundary:&lt;/P&gt;&lt;P&gt;-can be preceded, or ended by 0 characters (starting or end characters within variable)&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;-can be preceded, or ended by 1 or more spaces&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;-word containing a hyphen to be considered two words&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Apr 2018 14:07:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-PERL-string-count-for-address-var/m-p/451890#M283837</guid>
      <dc:creator>brulard</dc:creator>
      <dc:date>2018-04-06T14:07:01Z</dc:date>
    </item>
    <item>
      <title>Re: Help with PERL string count for address var</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-PERL-string-count-for-address-var/m-p/451916#M283838</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
infile cards dlm='|' truncover;
input @') ' address : $256.;
num=0;
do _n_=1 to countw(address,' -');
num+anydigit(scan(address,_n_,' -'))&amp;gt;0;
end;
cards;
()  189 ELIOT STREET | UNIT 112 | ROCKLAND | ON | K4K0G4 | CAN
(i)  1769 101A AVE | SURREY | BC | V4N5V8 | CAN
(ii) 1769 A101 AVE | SURREY | BC | V4N5V8 | CAN
(iii) 204 ALGONQUIN RD UNIT114 
(iv) BUREAU N2P1G1  106
(v) 29-549 RGE RD 232  STURGEON COUNTY  AB  T8L5E9  CAN
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 06 Apr 2018 14:46:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-PERL-string-count-for-address-var/m-p/451916#M283838</guid>
      <dc:creator>FriedEgg</dc:creator>
      <dc:date>2018-04-06T14:46:53Z</dc:date>
    </item>
    <item>
      <title>Re: Help with PERL string count for address var</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-PERL-string-count-for-address-var/m-p/452190#M283839</link>
      <description>&lt;P&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token datalines"&gt;&lt;SPAN class="token data string"&gt;"V4N5V8V&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&amp;nbsp;"&amp;nbsp; should be count&amp;nbsp; as 1 or 0 ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 07 Apr 2018 12:40:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-PERL-string-count-for-address-var/m-p/452190#M283839</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-04-07T12:40:01Z</dc:date>
    </item>
    <item>
      <title>Re: Help with PERL string count for address var</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-PERL-string-count-for-address-var/m-p/452473#M283840</link>
      <description>hi Ksharp... it is 1 in my example (although a zero could work, but should never be 2,or 3). I've struggled in perl with making count of example (ii) identical to count of (i) (and that is related to how /b function operates i believe</description>
      <pubDate>Mon, 09 Apr 2018 11:53:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-PERL-string-count-for-address-var/m-p/452473#M283840</guid>
      <dc:creator>brulard</dc:creator>
      <dc:date>2018-04-09T11:53:28Z</dc:date>
    </item>
  </channel>
</rss>

