<?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: String = A Math  B Cook V Deep  .Is there a way to get the output ABV using Compress function? in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/String-A-Math-B-Cook-V-Deep-Is-there-a-way-to-get-the-output-ABV/m-p/881310#M39085</link>
    <description>&lt;P&gt;Not, but a PRX function might do it (search for a capital character surrounded by blanks).&lt;/P&gt;</description>
    <pubDate>Sun, 18 Jun 2023 11:48:08 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2023-06-18T11:48:08Z</dc:date>
    <item>
      <title>String = A Math  B Cook V Deep  .Is there a way to get the output ABV using Compress function?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/String-A-Math-B-Cook-V-Deep-Is-there-a-way-to-get-the-output-ABV/m-p/881307#M39084</link>
      <description>&lt;P&gt;String = A Math B Cook V Deep .&lt;/P&gt;
&lt;P&gt;Is there a way to get the output ABV using Compress function.&lt;/P&gt;</description>
      <pubDate>Sun, 18 Jun 2023 11:16:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/String-A-Math-B-Cook-V-Deep-Is-there-a-way-to-get-the-output-ABV/m-p/881307#M39084</guid>
      <dc:creator>animesh123</dc:creator>
      <dc:date>2023-06-18T11:16:50Z</dc:date>
    </item>
    <item>
      <title>Re: String = A Math  B Cook V Deep  .Is there a way to get the output ABV using Compress function?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/String-A-Math-B-Cook-V-Deep-Is-there-a-way-to-get-the-output-ABV/m-p/881310#M39085</link>
      <description>&lt;P&gt;Not, but a PRX function might do it (search for a capital character surrounded by blanks).&lt;/P&gt;</description>
      <pubDate>Sun, 18 Jun 2023 11:48:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/String-A-Math-B-Cook-V-Deep-Is-there-a-way-to-get-the-output-ABV/m-p/881310#M39085</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-06-18T11:48:08Z</dc:date>
    </item>
    <item>
      <title>Re: String = A Math  B Cook V Deep  .Is there a way to get the output ABV using Compress function?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/String-A-Math-B-Cook-V-Deep-Is-there-a-way-to-get-the-output-ABV/m-p/881330#M39086</link>
      <description>&lt;P&gt;No.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That is NOT what COMPRESS() does.&amp;nbsp; It removes individual characters. So to get that result using COMPRESS() you would have to remove any character that wasn't A,B or V. Which would work for that one example, but I doubt it would work for other strings you might have.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the pattern is single letter followed by single word then use SCAN() function in a loop.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
   String = 'A Math B Cook V Deep';
   length next_word new_string $10 ;
   do i=1 by 2 until(next_word=' ');
     next_word=scan(string,i,' ');
     new_string=cats(new_string,next_word);
   end;
   drop i next_word;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If the pattern is more complex 'D Earth Science E Chemistry' then you will need something more complicated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the goal is to find single uppercase letters then then perhaps something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
   String = 'A Math B Cook V Deep';
   length next_word new_string $10 ;
   do i=1 to countw(string,' ');
     next_word=scan(string,i,' ');
     if length(next_word)=1 and 'A' &amp;lt;= next_word &amp;lt;= 'Z' then
       new_string=cats(new_string,next_word)
     ;
   end;
   drop i next_word;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If not then you will probably need to use regular expressions instead.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So if the pattern is remove any word that is more than one character then try&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
   String = 'A Math B Cook V Deep';
   length new_string $10 ;
   new_string=compress(prxchange('s/[^ ]{2,}//',-1,string),' ');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Jun 2023 18:12:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/String-A-Math-B-Cook-V-Deep-Is-there-a-way-to-get-the-output-ABV/m-p/881330#M39086</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-06-18T18:12:42Z</dc:date>
    </item>
  </channel>
</rss>

