<?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 Combining data from duplicative records in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Combining-data-from-duplicative-records/m-p/679273#M205106</link>
    <description>&lt;P&gt;I feel as if I have done this before, so this will most likely serve as a refresher.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have records identified here by "ID" which yield multiple records when joined with a "Type" field.&amp;nbsp; See my hypothetical example below.&amp;nbsp; Ideally, I want 1 row per "ID" with the different matching "types" concatenated and separated by a comma.&amp;nbsp; See here:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;What I have:&lt;/STRONG&gt;&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" style="height: 15.0pt; width: 48pt;"&gt;ID&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;Type&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;123&lt;/TD&gt;
&lt;TD&gt;A1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;456&lt;/TD&gt;
&lt;TD&gt;B4&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;123&lt;/TD&gt;
&lt;TD&gt;B4&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;567&lt;/TD&gt;
&lt;TD&gt;B4&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;234&lt;/TD&gt;
&lt;TD&gt;A1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;456&lt;/TD&gt;
&lt;TD&gt;A1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;123&lt;/TD&gt;
&lt;TD&gt;D2&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;What I want:&lt;/STRONG&gt;&lt;/P&gt;
&lt;TABLE width="158"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="64"&gt;ID&lt;/TD&gt;
&lt;TD width="94"&gt;Types&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;123&lt;/TD&gt;
&lt;TD&gt;A1, B4, D2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;234&lt;/TD&gt;
&lt;TD&gt;A1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;456&lt;/TD&gt;
&lt;TD&gt;B4, A1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;567&lt;/TD&gt;
&lt;TD&gt;B4&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any idea how to create the table I want from a table such as the one given before it?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 25 Aug 2020 19:23:23 GMT</pubDate>
    <dc:creator>RandoDando</dc:creator>
    <dc:date>2020-08-25T19:23:23Z</dc:date>
    <item>
      <title>Combining data from duplicative records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-data-from-duplicative-records/m-p/679273#M205106</link>
      <description>&lt;P&gt;I feel as if I have done this before, so this will most likely serve as a refresher.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have records identified here by "ID" which yield multiple records when joined with a "Type" field.&amp;nbsp; See my hypothetical example below.&amp;nbsp; Ideally, I want 1 row per "ID" with the different matching "types" concatenated and separated by a comma.&amp;nbsp; See here:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;What I have:&lt;/STRONG&gt;&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" style="height: 15.0pt; width: 48pt;"&gt;ID&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;Type&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;123&lt;/TD&gt;
&lt;TD&gt;A1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;456&lt;/TD&gt;
&lt;TD&gt;B4&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;123&lt;/TD&gt;
&lt;TD&gt;B4&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;567&lt;/TD&gt;
&lt;TD&gt;B4&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;234&lt;/TD&gt;
&lt;TD&gt;A1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;456&lt;/TD&gt;
&lt;TD&gt;A1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;123&lt;/TD&gt;
&lt;TD&gt;D2&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;What I want:&lt;/STRONG&gt;&lt;/P&gt;
&lt;TABLE width="158"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="64"&gt;ID&lt;/TD&gt;
&lt;TD width="94"&gt;Types&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;123&lt;/TD&gt;
&lt;TD&gt;A1, B4, D2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;234&lt;/TD&gt;
&lt;TD&gt;A1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;456&lt;/TD&gt;
&lt;TD&gt;B4, A1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;567&lt;/TD&gt;
&lt;TD&gt;B4&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any idea how to create the table I want from a table such as the one given before it?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Aug 2020 19:23:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-data-from-duplicative-records/m-p/679273#M205106</guid>
      <dc:creator>RandoDando</dc:creator>
      <dc:date>2020-08-25T19:23:23Z</dc:date>
    </item>
    <item>
      <title>Re: Combining data from duplicative records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-data-from-duplicative-records/m-p/679274#M205107</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input (ID	Type) ($);
cards;
123	A1
456	B4
123	B4
567	B4
234	A1
456	A1
123	D2
;

proc sort data=have out=_have;
 by id type;
run;

data want;
 do until(last.id);
  set _have;
  by id;
  length types $100;
  types=catx(',',types,type);
 end;
 drop type;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 25 Aug 2020 19:29:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-data-from-duplicative-records/m-p/679274#M205107</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-08-25T19:29:07Z</dc:date>
    </item>
    <item>
      <title>Re: Combining data from duplicative records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-data-from-duplicative-records/m-p/679277#M205109</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input (ID	Type) ($);
cards;
123	A1
456	B4
123	B4
567	B4
234	A1
456	A1
123	D2
;

data _null_;
 if _n_=1 then do;
  length types $100;
  dcl hash H () ;
  h.definekey  ("id") ;
  h.definedata ("id","types") ;
  h.definedone () ;
 end;
 do until(z);
  set have end=z;
  types=ifc(h.find()=0,catx(',',types,type),type);
  h.replace();
 end;
 if z;
 h.output(dataset:'want');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 25 Aug 2020 19:43:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-data-from-duplicative-records/m-p/679277#M205109</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-08-25T19:43:14Z</dc:date>
    </item>
    <item>
      <title>Re: Combining data from duplicative records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-data-from-duplicative-records/m-p/679278#M205110</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input (ID	Type) ($);
cards;
123	A1
456	B4
123	B4
567	B4
234	A1
456	A1
123	D2
;
proc sql;
 create view temp as
 select distinct id, type
 from have;
quit;

proc transpose data=temp out=temp2;
 by id;
 var type;
run;

data want;
 set temp2;
 length types $100;
 types=catx(',',of col:);
 drop col: _:;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 25 Aug 2020 19:52:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-data-from-duplicative-records/m-p/679278#M205110</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-08-25T19:52:38Z</dc:date>
    </item>
  </channel>
</rss>

