<?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: combine single letters in strings in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/combine-single-letters-in-strings/m-p/560082#M156524</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/98381"&gt;@somebody&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
company=" A C C O BRAND CORP";
run;

data want;
set have;
company=left(prxchange('s/(?&amp;lt;=(\b[A-Z])) (?=([A-Z]\b))//o',-1,propcase(company)));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The &lt;A href="https://documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=p0s9ilagexmjl8n1u7e1t1jfnzlk.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank" rel="noopener"&gt;Perl regular expression&lt;/A&gt; deletes single blanks which are preceded by a single uppercase letter (which is separated from preceding text, if any, by a word boundary) and followed&amp;nbsp;by another single uppercase letter (which is separated from subsequent text, if any, by a word boundary).&lt;/P&gt;</description>
    <pubDate>Mon, 20 May 2019 10:59:57 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2019-05-20T10:59:57Z</dc:date>
    <item>
      <title>combine single letters in strings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/combine-single-letters-in-strings/m-p/560074#M156518</link>
      <description>&lt;P&gt;I have a variable that contains company names. However, if a company name contains abbreviation, it creates space between the letters. For example, instead of "ACCO Brand Corp", the variable is " A C C O BRAND CORP". My question is, is there a way to group the ACCO together? Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 20 May 2019 10:26:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/combine-single-letters-in-strings/m-p/560074#M156518</guid>
      <dc:creator>somebody</dc:creator>
      <dc:date>2019-05-20T10:26:15Z</dc:date>
    </item>
    <item>
      <title>Re: combine single letters in strings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/combine-single-letters-in-strings/m-p/560081#M156523</link>
      <description>&lt;P&gt;Please share the code you are referring to when you say "it creates space between the letters".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) Is the original data in a SAS data set?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2) Is the output data in a SAS data set?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3) Please share the log with any messages.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;4) Please share some code and that can be run as is to demonstrate the problem, e.g., using &lt;FONT face="courier new,courier"&gt;dataines&lt;/FONT&gt; in a data step.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Amir.&lt;/P&gt;</description>
      <pubDate>Mon, 20 May 2019 10:56:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/combine-single-letters-in-strings/m-p/560081#M156523</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2019-05-20T10:56:10Z</dc:date>
    </item>
    <item>
      <title>Re: combine single letters in strings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/combine-single-letters-in-strings/m-p/560082#M156524</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/98381"&gt;@somebody&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
company=" A C C O BRAND CORP";
run;

data want;
set have;
company=left(prxchange('s/(?&amp;lt;=(\b[A-Z])) (?=([A-Z]\b))//o',-1,propcase(company)));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The &lt;A href="https://documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=p0s9ilagexmjl8n1u7e1t1jfnzlk.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank" rel="noopener"&gt;Perl regular expression&lt;/A&gt; deletes single blanks which are preceded by a single uppercase letter (which is separated from preceding text, if any, by a word boundary) and followed&amp;nbsp;by another single uppercase letter (which is separated from subsequent text, if any, by a word boundary).&lt;/P&gt;</description>
      <pubDate>Mon, 20 May 2019 10:59:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/combine-single-letters-in-strings/m-p/560082#M156524</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2019-05-20T10:59:57Z</dc:date>
    </item>
    <item>
      <title>Re: combine single letters in strings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/combine-single-letters-in-strings/m-p/560084#M156526</link>
      <description>&lt;P&gt;With "conventional" data step means:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
mystr = ' A C C O BRAND CORP';
*mystr = left(mystr);
i = 2;
do until (i &amp;gt;= length(mystr) or x&amp;gt;10);
  if substr(mystr,i,1) ne ' ' and substr(mystr,i-1,1) = ' ' and substr(mystr,i+1,1) = ' '
  then do;
    if i &amp;gt; 2
    then mystr = substr(mystr,1,i-2) !! substr(mystr,i);
	else mystr = substr(mystr,2);
  end;
  else i + 1;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 20 May 2019 11:04:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/combine-single-letters-in-strings/m-p/560084#M156526</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-05-20T11:04:28Z</dc:date>
    </item>
    <item>
      <title>Re: combine single letters in strings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/combine-single-letters-in-strings/m-p/560545#M156774</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
mystr = 'A C C O BRAND CORP';
temp=prxchange('s/(\w{2,})/ $1 /',-1,mystr);
want=compbl(prxchange('s/ (\w) /$1/',-1,temp));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 21 May 2019 15:03:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/combine-single-letters-in-strings/m-p/560545#M156774</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-05-21T15:03:28Z</dc:date>
    </item>
    <item>
      <title>Re: combine single letters in strings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/combine-single-letters-in-strings/m-p/560995#M156978</link>
      <description>&lt;P&gt;Thanks, your method works too. just one minor comment is that the result has a space at the start of the string.&lt;/P&gt;</description>
      <pubDate>Thu, 23 May 2019 00:08:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/combine-single-letters-in-strings/m-p/560995#M156978</guid>
      <dc:creator>somebody</dc:creator>
      <dc:date>2019-05-23T00:08:48Z</dc:date>
    </item>
    <item>
      <title>Re: combine single letters in strings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/combine-single-letters-in-strings/m-p/561096#M157024</link>
      <description>&lt;P&gt;Add one more function LEFT() around it .&lt;/P&gt;</description>
      <pubDate>Thu, 23 May 2019 11:26:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/combine-single-letters-in-strings/m-p/561096#M157024</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-05-23T11:26:05Z</dc:date>
    </item>
  </channel>
</rss>

