<?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 Duplicate Words in a String in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Remove-Duplicate-Words-in-a-String/m-p/839140#M331791</link>
    <description>Thanks! will take your advice for consideration.</description>
    <pubDate>Tue, 18 Oct 2022 09:17:41 GMT</pubDate>
    <dc:creator>abx</dc:creator>
    <dc:date>2022-10-18T09:17:41Z</dc:date>
    <item>
      <title>Remove Duplicate Words in a String</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-Duplicate-Words-in-a-String/m-p/837515#M331151</link>
      <description>&lt;P&gt;Hi All,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I currently learning SAS and would like to know if anyone is able to help out on the codes based on expected output.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Given samples are the duplicate name in string with some of the second name are truncated. I am not sure how to remove the duplicate name based on the expected output.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Name:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;John Smith John Smith&lt;BR /&gt;Jane Foster Jane Foste&lt;BR /&gt;Happy Garden Management Corporation Happy Garden Management C&lt;BR /&gt;ABC Car Workshop ABC Car Worksho&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Expected Output:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;John Smith&lt;BR /&gt;Jane Foster&lt;BR /&gt;Happy Garden Management Corporation&lt;BR /&gt;ABC Car Workshop&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 08 Oct 2022 11:03:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-Duplicate-Words-in-a-String/m-p/837515#M331151</guid>
      <dc:creator>abx</dc:creator>
      <dc:date>2022-10-08T11:03:59Z</dc:date>
    </item>
    <item>
      <title>Re: Remove Duplicate Words in a String</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-Duplicate-Words-in-a-String/m-p/837521#M331153</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/391547"&gt;@abx&lt;/a&gt;&amp;nbsp;and welcome to the SAS Support Communities!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/391547"&gt;@abx&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I currently learning SAS and would like to know if anyone is able to help out on the codes ...&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Actually, before we get to the &lt;EM&gt;code&lt;/EM&gt;, we would need a hard and fast &lt;EM&gt;rule&lt;/EM&gt; to be applied to the strings. Otherwise, we might suggest something like this ...&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input name $80.;
cards;
John Smith John Smith
Jane Foster Jane Foste
Happy Garden Management Corporation Happy Garden Management C
ABC Car Workshop ABC Car Worksho
;

data want(keep=name);
set have;
do i=2 to countw(name, ' ');
  call scan(name, i, pos, len, ' ');
  if trim(substr(name, pos)) =: name then do;
    name=substr(name, 1, pos-1);
    leave;
  end;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;... and then you come up with example strings like &lt;FONT face="courier new,courier"&gt;"KSU, Manhattan, KS"&lt;/FONT&gt;&amp;nbsp;where you don't want to cut off the abbreviation at the end.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But maybe there is no such problematic case in your data and the code above works for you.&lt;/P&gt;</description>
      <pubDate>Sat, 08 Oct 2022 13:46:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-Duplicate-Words-in-a-String/m-p/837521#M331153</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2022-10-08T13:46:00Z</dc:date>
    </item>
    <item>
      <title>Re: Remove Duplicate Words in a String</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-Duplicate-Words-in-a-String/m-p/837522#M331154</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/391547"&gt;@abx&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Leonid Batkhan has several interesting blogs about string treatment.&lt;/P&gt;
&lt;P&gt;Go to&amp;nbsp;&lt;A href="https://blogs.sas.com/content/?s=string+leonid" target="_blank"&gt;https://blogs.sas.com/content/?s=string+leonid&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;That is : go to&amp;nbsp;&lt;A href="https://blogs.sas.com/" target="_blank"&gt;https://blogs.sas.com/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;and enter "Leonid" and "string" as search terms, then hit ENTER.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I haven't opened it , but this one might be applicable :&lt;BR /&gt;Removing repeated characters in SAS strings &lt;BR /&gt;By Leonid Batkhan on SAS Users November 4, 2020&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/sgf/2020/11/04/removing-repeated-characters-in-sas-strings/" target="_blank"&gt;https://blogs.sas.com/content/sgf/2020/11/04/removing-repeated-characters-in-sas-strings/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Sat, 08 Oct 2022 13:47:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-Duplicate-Words-in-a-String/m-p/837522#M331154</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2022-10-08T13:47:46Z</dc:date>
    </item>
    <item>
      <title>Re: Remove Duplicate Words in a String</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-Duplicate-Words-in-a-String/m-p/837541#M331169</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/391547"&gt;@abx&lt;/a&gt;&amp;nbsp;This sort of data cleansing tasks become often quickly rather involved as you have also to deal with valid cases like Johnson &amp;amp; Johnson.&lt;/P&gt;
&lt;P&gt;I'd wait with it as an exercise until you're solid with the basics.&lt;/P&gt;</description>
      <pubDate>Sun, 09 Oct 2022 01:02:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-Duplicate-Words-in-a-String/m-p/837541#M331169</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2022-10-09T01:02:37Z</dc:date>
    </item>
    <item>
      <title>Re: Remove Duplicate Words in a String</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-Duplicate-Words-in-a-String/m-p/839140#M331791</link>
      <description>Thanks! will take your advice for consideration.</description>
      <pubDate>Tue, 18 Oct 2022 09:17:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-Duplicate-Words-in-a-String/m-p/839140#M331791</guid>
      <dc:creator>abx</dc:creator>
      <dc:date>2022-10-18T09:17:41Z</dc:date>
    </item>
    <item>
      <title>Re: Remove Duplicate Words in a String</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-Duplicate-Words-in-a-String/m-p/839141#M331792</link>
      <description>Thanks</description>
      <pubDate>Tue, 18 Oct 2022 09:18:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-Duplicate-Words-in-a-String/m-p/839141#M331792</guid>
      <dc:creator>abx</dc:creator>
      <dc:date>2022-10-18T09:18:37Z</dc:date>
    </item>
    <item>
      <title>Re: Remove Duplicate Words in a String</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-Duplicate-Words-in-a-String/m-p/839142#M331793</link>
      <description>Thank you for the tip.</description>
      <pubDate>Tue, 18 Oct 2022 09:19:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-Duplicate-Words-in-a-String/m-p/839142#M331793</guid>
      <dc:creator>abx</dc:creator>
      <dc:date>2022-10-18T09:19:03Z</dc:date>
    </item>
    <item>
      <title>Re: Remove Duplicate Words in a String</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-Duplicate-Words-in-a-String/m-p/839143#M331794</link>
      <description>Thank you for the links</description>
      <pubDate>Tue, 18 Oct 2022 09:19:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-Duplicate-Words-in-a-String/m-p/839143#M331794</guid>
      <dc:creator>abx</dc:creator>
      <dc:date>2022-10-18T09:19:19Z</dc:date>
    </item>
  </channel>
</rss>

