<?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 duplicate stages in the column by ',' delimeter in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Remove-duplicate-stages-in-the-column-by-delimeter/m-p/690973#M210253</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I need to list out the medical stages of the patients. In the output the values of each stage should be unique in order. I shared the example set below.&lt;SPAN style="background-color: #f5f5f5; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input ID Date1 mmddyy10. stages$10.;
format Date1 mmddyy10.;
cards;
123 02/05/2000 7,2,2
456 08/08/1999 5,5,1
789 07/02/2012 1,1
187 06/06/2003 7,9
753 12/12/1993 2,9,2,2,2
654 01/11/2001 2,9,2
321 04/05/2000 12,5,9,5
987 03/02/1999 14
178 05/06/1998 5
845 03/03/2020 9,9,9
159 09/08/2020 1,3,18
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Expected output :&amp;nbsp;&lt;/P&gt;
&lt;TABLE style="border-collapse: collapse; width: 96pt;" border="0" width="128" cellspacing="0" cellpadding="0"&gt;
&lt;TBODY&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="64" height="20" class="xl65" style="height: 15.0pt; width: 48pt;"&gt;stages&lt;/TD&gt;
&lt;TD width="64" class="xl66" style="width: 48pt;"&gt;Stg&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="64" height="20" class="xl67" style="height: 15.0pt; width: 48pt;"&gt;7,2,2&lt;/TD&gt;
&lt;TD class="xl66"&gt;7,2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="64" height="20" class="xl67" style="height: 15.0pt; width: 48pt;"&gt;5,5,1&lt;/TD&gt;
&lt;TD class="xl66"&gt;5,1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="64" height="20" class="xl67" style="height: 15.0pt; width: 48pt;"&gt;1,1&lt;/TD&gt;
&lt;TD class="xl66"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="64" height="20" class="xl67" style="height: 15.0pt; width: 48pt;"&gt;7,9&lt;/TD&gt;
&lt;TD class="xl66"&gt;7,9&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="64" height="20" class="xl67" style="height: 15.0pt; width: 48pt;"&gt;2,9,2,2,2&lt;/TD&gt;
&lt;TD class="xl66"&gt;9,2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="64" height="20" class="xl67" style="height: 15.0pt; width: 48pt;"&gt;2,9,2&lt;/TD&gt;
&lt;TD class="xl66"&gt;9,2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="64" height="20" class="xl67" style="height: 15.0pt; width: 48pt;"&gt;12,5,9,5&lt;/TD&gt;
&lt;TD class="xl66"&gt;12,9,5&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="64" height="20" class="xl67" style="height: 15.0pt; width: 48pt;"&gt;14&lt;/TD&gt;
&lt;TD class="xl66"&gt;14&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="64" height="20" class="xl67" style="height: 15.0pt; width: 48pt;"&gt;5&lt;/TD&gt;
&lt;TD class="xl66"&gt;5&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="64" height="20" class="xl67" style="height: 15.0pt; width: 48pt;"&gt;9,9,9&lt;/TD&gt;
&lt;TD class="xl66"&gt;9&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="64" height="20" class="xl67" style="height: 15.0pt; width: 48pt;"&gt;1,3,18&lt;/TD&gt;
&lt;TD class="xl66"&gt;1,3,18&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;The values should matches the corresponding ID and date.&lt;/P&gt;
&lt;P&gt;Kindly suggest a code.&lt;/P&gt;
&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
    <pubDate>Mon, 12 Oct 2020 13:38:56 GMT</pubDate>
    <dc:creator>Sathish_jammy</dc:creator>
    <dc:date>2020-10-12T13:38:56Z</dc:date>
    <item>
      <title>Remove duplicate stages in the column by ',' delimeter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-duplicate-stages-in-the-column-by-delimeter/m-p/690973#M210253</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I need to list out the medical stages of the patients. In the output the values of each stage should be unique in order. I shared the example set below.&lt;SPAN style="background-color: #f5f5f5; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input ID Date1 mmddyy10. stages$10.;
format Date1 mmddyy10.;
cards;
123 02/05/2000 7,2,2
456 08/08/1999 5,5,1
789 07/02/2012 1,1
187 06/06/2003 7,9
753 12/12/1993 2,9,2,2,2
654 01/11/2001 2,9,2
321 04/05/2000 12,5,9,5
987 03/02/1999 14
178 05/06/1998 5
845 03/03/2020 9,9,9
159 09/08/2020 1,3,18
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Expected output :&amp;nbsp;&lt;/P&gt;
&lt;TABLE style="border-collapse: collapse; width: 96pt;" border="0" width="128" cellspacing="0" cellpadding="0"&gt;
&lt;TBODY&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="64" height="20" class="xl65" style="height: 15.0pt; width: 48pt;"&gt;stages&lt;/TD&gt;
&lt;TD width="64" class="xl66" style="width: 48pt;"&gt;Stg&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="64" height="20" class="xl67" style="height: 15.0pt; width: 48pt;"&gt;7,2,2&lt;/TD&gt;
&lt;TD class="xl66"&gt;7,2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="64" height="20" class="xl67" style="height: 15.0pt; width: 48pt;"&gt;5,5,1&lt;/TD&gt;
&lt;TD class="xl66"&gt;5,1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="64" height="20" class="xl67" style="height: 15.0pt; width: 48pt;"&gt;1,1&lt;/TD&gt;
&lt;TD class="xl66"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="64" height="20" class="xl67" style="height: 15.0pt; width: 48pt;"&gt;7,9&lt;/TD&gt;
&lt;TD class="xl66"&gt;7,9&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="64" height="20" class="xl67" style="height: 15.0pt; width: 48pt;"&gt;2,9,2,2,2&lt;/TD&gt;
&lt;TD class="xl66"&gt;9,2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="64" height="20" class="xl67" style="height: 15.0pt; width: 48pt;"&gt;2,9,2&lt;/TD&gt;
&lt;TD class="xl66"&gt;9,2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="64" height="20" class="xl67" style="height: 15.0pt; width: 48pt;"&gt;12,5,9,5&lt;/TD&gt;
&lt;TD class="xl66"&gt;12,9,5&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="64" height="20" class="xl67" style="height: 15.0pt; width: 48pt;"&gt;14&lt;/TD&gt;
&lt;TD class="xl66"&gt;14&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="64" height="20" class="xl67" style="height: 15.0pt; width: 48pt;"&gt;5&lt;/TD&gt;
&lt;TD class="xl66"&gt;5&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="64" height="20" class="xl67" style="height: 15.0pt; width: 48pt;"&gt;9,9,9&lt;/TD&gt;
&lt;TD class="xl66"&gt;9&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="64" height="20" class="xl67" style="height: 15.0pt; width: 48pt;"&gt;1,3,18&lt;/TD&gt;
&lt;TD class="xl66"&gt;1,3,18&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;The values should matches the corresponding ID and date.&lt;/P&gt;
&lt;P&gt;Kindly suggest a code.&lt;/P&gt;
&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Mon, 12 Oct 2020 13:38:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-duplicate-stages-in-the-column-by-delimeter/m-p/690973#M210253</guid>
      <dc:creator>Sathish_jammy</dc:creator>
      <dc:date>2020-10-12T13:38:56Z</dc:date>
    </item>
    <item>
      <title>Re: Remove duplicate stages in the column by ',' delimeter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-duplicate-stages-in-the-column-by-delimeter/m-p/690981#M210256</link>
      <description>&lt;P&gt;HI&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/215282"&gt;@Sathish_jammy&lt;/a&gt;&amp;nbsp; There are multiple ways to approach the solution to your question. The idea is to evaluate&lt;/P&gt;
&lt;P&gt;1. what would be the shortest path or the quickest path?&lt;/P&gt;
&lt;P&gt;2. Whether linear or random binary search&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A slow linear could mean many approaches which will get the job done perhaps using REGEX and other methods and so forth.&amp;nbsp; I personally would like to approach with a HASH solution as I am biased to approaches/methodology devised and taught by Guru Paul D&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;

data have;
input ID Date1 mmddyy10. stages$10.;
format Date1 mmddyy10.;
cards;
123 02/05/2000 7,2,2
456 08/08/1999 5,5,1
789 07/02/2012 1,1
187 06/06/2003 7,9
753 12/12/1993 2,9,2,2,2
654 01/11/2001 2,9,2
321 04/05/2000 12,5,9,5
987 03/02/1999 14
178 05/06/1998 5
845 03/03/2020 9,9,9
159 09/08/2020 1,3,18
;


data want;
 if _n_=1 then do;
  dcl hash H () ;
  h.definekey  ("_temp") ;
  h.definedone () ;
 end;
 set have;
 length stg $100;
 do _n_=1 to countw(stages,',');
  _temp=scan(stages,_n_,',');
  if h.check() ne 0 then do;
   Stg=catx(',',Stg,_temp);
   h.add();
  end;
 end;
 h.clear();
 keep stages stg;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Oct 2020 18:26:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-duplicate-stages-in-the-column-by-delimeter/m-p/690981#M210256</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-10-12T18:26:23Z</dc:date>
    </item>
  </channel>
</rss>

