<?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: remove words from string if the word length is lower than 4 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/remove-words-from-string-if-the-word-length-is-lower-than-4/m-p/680633#M205739</link>
    <description>&lt;P&gt;The answer supplied by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt;&amp;nbsp;is almost there. Except that you may get leading blanks and double blanks in your output, they can be removed by LEFT and COMPBL:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
   s = "The copmany LLTX inc";
   n = left(compbl(prxchange("s/\b\w{1,3}\b//", -1, s)));
   put n $quote.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I changed the demonstration example to a DATA _NULL_, as this makes it easier to see the result in the log, with quotes so that you can easily see the leading blanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The PRX expression looks for a word boundary(\b), followed by one to three "word" characters (letter, numbers and underscores, that's \w) and then another word boundary, and that expression is changed to nothing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you also want to get rid of other sets of non-blank characters, such as "f.3" or "1,5", you can change the \w to \S, which means any non-blank character.&lt;/P&gt;</description>
    <pubDate>Tue, 01 Sep 2020 07:06:07 GMT</pubDate>
    <dc:creator>s_lassen</dc:creator>
    <dc:date>2020-09-01T07:06:07Z</dc:date>
    <item>
      <title>remove words from string if the word length is lower than 4</title>
      <link>https://communities.sas.com/t5/SAS-Programming/remove-words-from-string-if-the-word-length-is-lower-than-4/m-p/680617#M205725</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;How can I remove words from string if the word length is lower than 4?&lt;/P&gt;
&lt;P&gt;For example:&lt;/P&gt;
&lt;P&gt;For string "The copmany LLTX inc"&amp;nbsp; I will get "company LLTX"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Sep 2020 06:13:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/remove-words-from-string-if-the-word-length-is-lower-than-4/m-p/680617#M205725</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2020-09-01T06:13:02Z</dc:date>
    </item>
    <item>
      <title>Re: remove words from string if the word length is lower than 4</title>
      <link>https://communities.sas.com/t5/SAS-Programming/remove-words-from-string-if-the-word-length-is-lower-than-4/m-p/680624#M205732</link>
      <description>&lt;P&gt;What have you tried so far?&lt;/P&gt;
&lt;P&gt;Countw, loop over the string, Scan each word, Length function for each word, build new string with CATX function.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Sep 2020 06:41:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/remove-words-from-string-if-the-word-length-is-lower-than-4/m-p/680624#M205732</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-09-01T06:41:30Z</dc:date>
    </item>
    <item>
      <title>Re: remove words from string if the word length is lower than 4</title>
      <link>https://communities.sas.com/t5/SAS-Programming/remove-words-from-string-if-the-word-length-is-lower-than-4/m-p/680626#M205734</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
   s = "The copmany LLTX inc";
   n = prxchange("s/\b\w{1,3}\b//", -1, s);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 01 Sep 2020 06:44:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/remove-words-from-string-if-the-word-length-is-lower-than-4/m-p/680626#M205734</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-09-01T06:44:24Z</dc:date>
    </item>
    <item>
      <title>Re: remove words from string if the word length is lower than 4</title>
      <link>https://communities.sas.com/t5/SAS-Programming/remove-words-from-string-if-the-word-length-is-lower-than-4/m-p/680627#M205735</link>
      <description>&lt;P&gt;I am almost sure that this problem can be solved by using a regular expression and that is you will find code if you would search for it.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Sep 2020 06:44:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/remove-words-from-string-if-the-word-length-is-lower-than-4/m-p/680627#M205735</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2020-09-01T06:44:56Z</dc:date>
    </item>
    <item>
      <title>Re: remove words from string if the word length is lower than 4</title>
      <link>https://communities.sas.com/t5/SAS-Programming/remove-words-from-string-if-the-word-length-is-lower-than-4/m-p/680633#M205739</link>
      <description>&lt;P&gt;The answer supplied by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt;&amp;nbsp;is almost there. Except that you may get leading blanks and double blanks in your output, they can be removed by LEFT and COMPBL:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
   s = "The copmany LLTX inc";
   n = left(compbl(prxchange("s/\b\w{1,3}\b//", -1, s)));
   put n $quote.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I changed the demonstration example to a DATA _NULL_, as this makes it easier to see the result in the log, with quotes so that you can easily see the leading blanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The PRX expression looks for a word boundary(\b), followed by one to three "word" characters (letter, numbers and underscores, that's \w) and then another word boundary, and that expression is changed to nothing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you also want to get rid of other sets of non-blank characters, such as "f.3" or "1,5", you can change the \w to \S, which means any non-blank character.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Sep 2020 07:06:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/remove-words-from-string-if-the-word-length-is-lower-than-4/m-p/680633#M205739</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2020-09-01T07:06:07Z</dc:date>
    </item>
    <item>
      <title>Re: remove words from string if the word length is lower than 4</title>
      <link>https://communities.sas.com/t5/SAS-Programming/remove-words-from-string-if-the-word-length-is-lower-than-4/m-p/680635#M205740</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/76464"&gt;@s_lassen&lt;/a&gt;&amp;nbsp;good catch.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Sep 2020 07:13:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/remove-words-from-string-if-the-word-length-is-lower-than-4/m-p/680635#M205740</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-09-01T07:13:23Z</dc:date>
    </item>
  </channel>
</rss>

