<?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 Remove Redundant Words in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Remove-Redundant-Words/m-p/526881#M143579</link>
    <description>&lt;P&gt;I have a data set with two variables &lt;STRONG&gt;Enrolid and Index_Therapy&lt;/STRONG&gt;. Under index_therapy i have data with duplicate values in the string for each record, I would need a code to remove duplicates from each string.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sample data set is attached.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sample data.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/26249i200189EA2D1FEF9D/image-size/large?v=v2&amp;amp;px=999" role="button" title="sample data.PNG" alt="sample data.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Output data set&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Enrolid&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;Index_Therapy&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;114101&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;SPAN&gt;Sorafenib,Erlotinib&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;2086103&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;SPAN&gt;Sorafenib&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;102950901&amp;nbsp;Sorafenib&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;117102901&amp;nbsp;Sorafenib,Radio&amp;nbsp; &amp;nbsp; etc&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 14 Jan 2019 09:10:27 GMT</pubDate>
    <dc:creator>Guptashwe</dc:creator>
    <dc:date>2019-01-14T09:10:27Z</dc:date>
    <item>
      <title>Remove Redundant Words</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-Redundant-Words/m-p/526881#M143579</link>
      <description>&lt;P&gt;I have a data set with two variables &lt;STRONG&gt;Enrolid and Index_Therapy&lt;/STRONG&gt;. Under index_therapy i have data with duplicate values in the string for each record, I would need a code to remove duplicates from each string.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sample data set is attached.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sample data.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/26249i200189EA2D1FEF9D/image-size/large?v=v2&amp;amp;px=999" role="button" title="sample data.PNG" alt="sample data.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Output data set&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Enrolid&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;Index_Therapy&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;114101&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;SPAN&gt;Sorafenib,Erlotinib&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;2086103&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;SPAN&gt;Sorafenib&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;102950901&amp;nbsp;Sorafenib&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;117102901&amp;nbsp;Sorafenib,Radio&amp;nbsp; &amp;nbsp; etc&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Jan 2019 09:10:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-Redundant-Words/m-p/526881#M143579</guid>
      <dc:creator>Guptashwe</dc:creator>
      <dc:date>2019-01-14T09:10:27Z</dc:date>
    </item>
    <item>
      <title>Re: Remove Redundant Words</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-Redundant-Words/m-p/526884#M143580</link>
      <description>&lt;P&gt;Create a new string, and check if a word is already present in it:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set problem_1 (rename=(index_therapy=_index_therapy));
length index_therapy $400;
do i = 1 to countw(_index_therapy,',');
  word = scan(_index_therapy,i,',');
  if not findw(index_therapy,strip(word),', ')
  then index_therapy = catx(',',index_therapy,word);
end;
keep enrolid index_therapy;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that "Need Help" does not meet the requirements for a descriptive subject line. Be a little more creative next time.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Jan 2019 09:12:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-Redundant-Words/m-p/526884#M143580</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-01-14T09:12:21Z</dc:date>
    </item>
    <item>
      <title>Re: Remove Redundant Words</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-Redundant-Words/m-p/526885#M143581</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is an alternate solution..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Enrolid Index_Therapy $40.;
datalines;
114101 Sorafenib,Sorafenib,Sorafenib,Erlotinib
2086103 Sorafenib,Sorafenib,Sorafenib
102950901 Sorafenib,Sorafenib
117102901 Sorafenib,Radio,Radio
;
run;

DATA HAVE1;
SET HAVE;
DO I=1 TO COUNT(Index_Therapy,',')+1;
 Index_Therapy_=SCAN(Index_Therapy,I,',');
 OUTPUT;
END;
DROP I Index_Therapy;
RUN; 
 
PROC SORT DATA=HAVE1 OUT=HAVE2 NODUP;
BY  Enrolid Index_Therapy_;
RUN;
 
DATA WANT;
SET HAVE2;
BY  Enrolid Index_Therapy_;
RETAIN Index_Therapy;
IF FIRST.Enrolid THEN Index_Therapy=Index_Therapy_;
 ELSE  Index_Therapy=CATX(',',Index_Therapy,Index_Therapy_);
 IF LAST.Enrolid ;
 DROP Index_Therapy_;
RUN;
 &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks..&lt;/P&gt;</description>
      <pubDate>Mon, 14 Jan 2019 09:37:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-Redundant-Words/m-p/526885#M143581</guid>
      <dc:creator>singhsahab</dc:creator>
      <dc:date>2019-01-14T09:37:23Z</dc:date>
    </item>
    <item>
      <title>Re: Remove Redundant Words</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-Redundant-Words/m-p/527247#M143703</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Enrolid Index_Therapy $40.;
datalines;
114101 Sorafenib,Sorafenib,Sorafenib,Erlotinib
2086103 Sorafenib,Sorafenib,Sorafenib
102950901 Sorafenib,Sorafenib
117102901 Sorafenib,Radio,Radio
;
run;

data want;
 set have;
 array x{999} $ 80 _temporary_;
 length want $ 200;
 call missing(of x{*});
 n=0;
 do i=1 to countw(Index_Therapy,',');
  temp=scan(Index_Therapy,i,',');
  if temp not in x then do;n+1;x{n}=temp;end;
 end;
 want=catx(',',of x{*});
 drop n i temp;
run;
 &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 15 Jan 2019 09:23:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-Redundant-Words/m-p/527247#M143703</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-01-15T09:23:16Z</dc:date>
    </item>
  </channel>
</rss>

