<?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: Delete the last words of a sentence in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Delete-the-last-words-of-a-sentence/m-p/373945#M89484</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
newstring = string; /* to get the same length */
newstring = ' ';
do i = 1 to countw(string) - 2;
  newstring = catx(' ',newstring,scan(string,i));
end;
drop string;
rename newstring=string;
run;
  &lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 07 Jul 2017 12:52:12 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2017-07-07T12:52:12Z</dc:date>
    <item>
      <title>Delete the last words of a sentence</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-the-last-words-of-a-sentence/m-p/373941#M89481</link>
      <description>&lt;P&gt;Hello.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a problem on deleting the last words of a sentense.&lt;/P&gt;&lt;P&gt;So, here is the details of the problem:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the column contains models of phones with colors, I must eliminate the colors and needless details from&amp;nbsp;it, there are cases when the models contain two type of colors or&amp;nbsp;details, for instance&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Alcatel One Touch POP C7 Bluish Black&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;iPhone 6 S 32 GB Full Gold&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;I want to delete the last two "words" if they are colors or details. how to do&amp;nbsp;it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you a lot.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jul 2017 12:35:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-the-last-words-of-a-sentence/m-p/373941#M89481</guid>
      <dc:creator>Garik</dc:creator>
      <dc:date>2017-07-07T12:35:04Z</dc:date>
    </item>
    <item>
      <title>Re: Delete the last words of a sentence</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-the-last-words-of-a-sentence/m-p/373942#M89482</link>
      <description>&lt;P&gt;Alcatel One Touch Idol 2 Mini S &lt;FONT color="#FF0000"&gt;&lt;EM&gt;&lt;STRONG&gt;Slate White&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;Alcatel One Touch POP C5 &lt;FONT color="#FF0000"&gt;&lt;EM&gt;&lt;STRONG&gt;Dark Grey&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;Alcatel One Touch POP C5 &lt;FONT color="#FF0000"&gt;&lt;EM&gt;&lt;STRONG&gt;Pure White&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;Alcatel One Touch POP C7 &lt;FONT color="#FF0000"&gt;&lt;EM&gt;&lt;STRONG&gt;Bluish Black&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;Alcatel One Touch POP C7 &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;&lt;EM&gt;Full White&lt;/EM&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jul 2017 12:44:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-the-last-words-of-a-sentence/m-p/373942#M89482</guid>
      <dc:creator>Garik</dc:creator>
      <dc:date>2017-07-07T12:44:53Z</dc:date>
    </item>
    <item>
      <title>Re: Delete the last words of a sentence</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-the-last-words-of-a-sentence/m-p/373944#M89483</link>
      <description>&lt;P&gt;And what is the logic for know that either the last, or last two words are to do with color? &amp;nbsp;"Full" for instance has nothing logically to do with color. &amp;nbsp;I would suggest you build a list of strings, or combination of possibles, and use that to remove information from the string, e.g.:&lt;/P&gt;
&lt;PRE&gt;data colors;
  color="SLATE WHITE"; output;
  color="DARK GREY"; output;
  color="GREY"; output;
...
run;&lt;BR /&gt;proc sql;&lt;BR /&gt;  create table WANT as &lt;BR /&gt;  select  tranwrd(A.STRING,B.COLOR) as STRING&lt;BR /&gt;  from    HAVE A&lt;BR /&gt;  left join COLORS&lt;BR /&gt;  on      index(A.STRING,B.COLOR) &amp;gt; 0;&lt;BR /&gt;quit;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jul 2017 12:49:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-the-last-words-of-a-sentence/m-p/373944#M89483</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-07-07T12:49:55Z</dc:date>
    </item>
    <item>
      <title>Re: Delete the last words of a sentence</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-the-last-words-of-a-sentence/m-p/373945#M89484</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
newstring = string; /* to get the same length */
newstring = ' ';
do i = 1 to countw(string) - 2;
  newstring = catx(' ',newstring,scan(string,i));
end;
drop string;
rename newstring=string;
run;
  &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 07 Jul 2017 12:52:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-the-last-words-of-a-sentence/m-p/373945#M89484</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-07-07T12:52:12Z</dc:date>
    </item>
    <item>
      <title>Re: Delete the last words of a sentence</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-the-last-words-of-a-sentence/m-p/373946#M89485</link>
      <description>&lt;P&gt;thanks for replay;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But, could you write the same code for sas, I am not familiar with sql.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jul 2017 12:53:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-the-last-words-of-a-sentence/m-p/373946#M89485</guid>
      <dc:creator>Garik</dc:creator>
      <dc:date>2017-07-07T12:53:23Z</dc:date>
    </item>
    <item>
      <title>Re: Delete the last words of a sentence</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-the-last-words-of-a-sentence/m-p/373951#M89487</link>
      <description>&lt;P&gt;&amp;nbsp;can I use an array if I must check if the last two words are needless words? Suppose I have the list of the "words" that must be deleted from the string.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jul 2017 13:03:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-the-last-words-of-a-sentence/m-p/373951#M89487</guid>
      <dc:creator>Garik</dc:creator>
      <dc:date>2017-07-07T13:03:33Z</dc:date>
    </item>
    <item>
      <title>Re: Delete the last words of a sentence</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-the-last-words-of-a-sentence/m-p/373953#M89488</link>
      <description>&lt;P&gt;Not without a lot of code. &amp;nbsp;You will see the join is on the value of one being within the string of the other (the index()). &amp;nbsp;This is difficult to do in base SAS. &amp;nbsp;Its really worth learning SQL, its relatively simple and very powerful on joins.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jul 2017 13:08:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-the-last-words-of-a-sentence/m-p/373953#M89488</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-07-07T13:08:59Z</dc:date>
    </item>
  </channel>
</rss>

