<?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: unify strings to 'UK'? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/unify-strings-to-UK/m-p/546559#M151336</link>
    <description>&lt;P&gt;thanks&amp;nbsp;&lt;/P&gt;&lt;P&gt;I expect to get&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ABC (UK)
ABC (UK)
ABC [UK]
ABCU. K.  /*this one should not be unified*/
ABC {UK}
ABC 'UK'
AB C UK&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 27 Mar 2019 15:31:25 GMT</pubDate>
    <dc:creator>Alexxxxxxx</dc:creator>
    <dc:date>2019-03-27T15:31:25Z</dc:date>
    <item>
      <title>unify strings to 'UK'?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/unify-strings-to-UK/m-p/546543#M151328</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I unify below strings to 'UK'?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;
  infile datalines truncover;
  input name $100.;
  datalines;
ABC (U.K.)
ABC (U K )
ABC [U.K.]
ABCU. K.  /*this one should not be unified*/
ABC {U. K.}
ABC 'U K'
AB C U K
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I expect to get&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ABC (UK)
ABC (UK)
ABC [UK]
ABCU. K.  /*this one should not be unified*/
ABC {UK}
ABC 'UK'
AB C UK&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you please give me some suggestions about this?&lt;/P&gt;&lt;P&gt;thanks in advance&lt;/P&gt;</description>
      <pubDate>Wed, 27 Mar 2019 15:31:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/unify-strings-to-UK/m-p/546543#M151328</guid>
      <dc:creator>Alexxxxxxx</dc:creator>
      <dc:date>2019-03-27T15:31:01Z</dc:date>
    </item>
    <item>
      <title>Re: unify strings to 'UK'?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/unify-strings-to-UK/m-p/546551#M151330</link>
      <description>&lt;P&gt;Please post what you expect as output for each observation.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Mar 2019 15:15:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/unify-strings-to-UK/m-p/546551#M151330</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2019-03-27T15:15:35Z</dc:date>
    </item>
    <item>
      <title>Re: unify strings to 'UK'?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/unify-strings-to-UK/m-p/546555#M151334</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You might have to adapt a bit depending on the specific behavior you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
unif=prxchange("s/\bU\b[. ]+\bK\b[. ]+/UK/i",-1,name);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Edit : I slighly modified the regular expression after your reply to &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15475"&gt;@andreas_lds&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Mar 2019 15:35:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/unify-strings-to-UK/m-p/546555#M151334</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2019-03-27T15:35:06Z</dc:date>
    </item>
    <item>
      <title>Re: unify strings to 'UK'?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/unify-strings-to-UK/m-p/546559#M151336</link>
      <description>&lt;P&gt;thanks&amp;nbsp;&lt;/P&gt;&lt;P&gt;I expect to get&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ABC (UK)
ABC (UK)
ABC [UK]
ABCU. K.  /*this one should not be unified*/
ABC {UK}
ABC 'UK'
AB C UK&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Mar 2019 15:31:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/unify-strings-to-UK/m-p/546559#M151336</guid>
      <dc:creator>Alexxxxxxx</dc:creator>
      <dc:date>2019-03-27T15:31:25Z</dc:date>
    </item>
    <item>
      <title>Re: unify strings to 'UK'?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/unify-strings-to-UK/m-p/546586#M151346</link>
      <description>&lt;P&gt;Dear&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/30622"&gt;@gamotte&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks for your code,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but the&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ABC 'U K'&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;is not been processed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Besides,&amp;nbsp; Could you please introduce some manual to learn the meaning of following codes&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token string"&gt;s/\bU\b[. ]+\bK\b[. ]+/UK/i&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;and what is the type/name of this code?(i.e., how do you call this code?)&lt;/P&gt;</description>
      <pubDate>Wed, 27 Mar 2019 16:41:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/unify-strings-to-UK/m-p/546586#M151346</guid>
      <dc:creator>Alexxxxxxx</dc:creator>
      <dc:date>2019-03-27T16:41:54Z</dc:date>
    </item>
    <item>
      <title>Re: unify strings to 'UK'?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/unify-strings-to-UK/m-p/546591#M151351</link>
      <description>&lt;P&gt;Look for "perl regexp" in google.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here \b means a word boundary.&lt;/P&gt;
&lt;P&gt;[. ] means a space or a period&lt;/P&gt;
&lt;P&gt;[. ]+ means one or more spaces/periods&lt;/P&gt;
&lt;P&gt;U and K are the letters U and K&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In ABC 'U K', K is followed by ' and so does not match the regexp.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can drop the final [. ]+&lt;/P&gt;
&lt;PRE class="  language-sas"&gt;&lt;CODE class="  language-sas"&gt;s&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;\&lt;/SPAN&gt;bU&lt;SPAN class="token punctuation"&gt;\&lt;/SPAN&gt;b&lt;SPAN class="token punctuation"&gt;[&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;]&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;+&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;\&lt;/SPAN&gt;bK&lt;SPAN class="token punctuation"&gt;\&lt;/SPAN&gt;b&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt;UK&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt;i&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Mar 2019 16:54:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/unify-strings-to-UK/m-p/546591#M151351</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2019-03-27T16:54:56Z</dc:date>
    </item>
    <item>
      <title>Re: unify strings to 'UK'?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/unify-strings-to-UK/m-p/546749#M151438</link>
      <description>&lt;P&gt;I would run this to cover more cases:&lt;/P&gt;
&lt;PRE&gt;UNIF=prxchange("s/ [^\w\d]*U[^\w\d]+K[^\w\d]*$/ UK/i",1,NAME);&lt;/PRE&gt;
&lt;P&gt;This cleans:&lt;/P&gt;
&lt;P&gt;space&lt;/P&gt;
&lt;P&gt;followed by optional non-alphanumerics&amp;nbsp;&lt;/P&gt;
&lt;P&gt;followed by U&lt;/P&gt;
&lt;P&gt;followed by non-alphanumerics&amp;nbsp;&lt;/P&gt;
&lt;P&gt;followded by K&lt;/P&gt;
&lt;P&gt;followed by optional non-alphanumerics&amp;nbsp;&lt;/P&gt;
&lt;P&gt;then end of string&lt;/P&gt;
&lt;P&gt;The final&lt;FONT face="courier new,courier"&gt; i&lt;/FONT&gt; make this case insensitive, which may not be what you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Mar 2019 22:12:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/unify-strings-to-UK/m-p/546749#M151438</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-03-28T22:12:19Z</dc:date>
    </item>
    <item>
      <title>Re: unify strings to 'UK'?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/unify-strings-to-UK/m-p/546905#M151498</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;
  infile datalines truncover;
  input name $100.;
  datalines;
ABC (U.K.)
ABC (U K )
ABC [U.K.]
ABCU. K.  /*this one should not be unified*/
ABC {U. K.}
ABC 'U K'
AB C U K
;
run;

data want;
 set have;
 pid=prxparse('/\bu\W+k\b/i');
 call prxsubstr(pid,name,p,l);
 if p&amp;gt;0 then do; 
 if substr(name,p+l,1) in (' ' '.') then l=l+1;
 substr(name,p,l)= 'UK'; 
 end;
run;
proc print;run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 28 Mar 2019 14:15:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/unify-strings-to-UK/m-p/546905#M151498</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-03-28T14:15:45Z</dc:date>
    </item>
  </channel>
</rss>

