<?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: collapse multiple records into unique one and add column value in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/collapse-multiple-records-into-unique-one-and-add-column-value/m-p/255307#M48750</link>
    <description>&lt;P&gt;thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh﻿&lt;/a&gt;&amp;nbsp;for your help&lt;/P&gt;</description>
    <pubDate>Tue, 08 Mar 2016 17:56:24 GMT</pubDate>
    <dc:creator>samnan</dc:creator>
    <dc:date>2016-03-08T17:56:24Z</dc:date>
    <item>
      <title>collapse multiple records into unique one and add column value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/collapse-multiple-records-into-unique-one-and-add-column-value/m-p/255297#M48747</link>
      <description>&lt;P&gt;Hi;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i have large data set look like as&amp;nbsp;following,&amp;nbsp;where for each (id) there are 5 (type)s that have&amp;nbsp;(value) and (count). what i want is to transpose these (type)s and add any same (value), in addtion to&amp;nbsp;the summation of&amp;nbsp;(count) for the unique (id).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;input id type value count;&lt;BR /&gt;cards;&lt;BR /&gt;1 1 32 2&lt;BR /&gt;1 3 54 1&lt;BR /&gt;1 1 10 7&lt;BR /&gt;1 2 20 10&lt;BR /&gt;1 5 56 0&lt;BR /&gt;1 4 68 2&lt;BR /&gt;1 2 59 2&lt;BR /&gt;1 3 82 4&lt;BR /&gt;2 1 52 8&lt;BR /&gt;2 5 64 9&lt;BR /&gt;2 3 76 6&lt;BR /&gt;2 4 98 8&lt;BR /&gt;2 2 39 9&lt;BR /&gt;2 4 96 5&lt;BR /&gt;3 1 58 2&lt;BR /&gt;3 2 63 6&lt;BR /&gt;3 4 72 3&lt;BR /&gt;3 5 99 4&lt;BR /&gt;3 3 37 1&lt;BR /&gt;3 1 66 0&lt;BR /&gt;;&lt;BR /&gt;data want;&lt;BR /&gt;input id type_1 type_2 type_3 type_4 type_5 count;&lt;BR /&gt;cards;&lt;BR /&gt;1 42 79 136 68 56 28&lt;BR /&gt;2 52 39 76 194 64 45&lt;BR /&gt;3 124 63 37 72 99 16&lt;BR /&gt;;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;any help or suggestion is appreciated.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Mar 2016 17:04:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/collapse-multiple-records-into-unique-one-and-add-column-value/m-p/255297#M48747</guid>
      <dc:creator>samnan</dc:creator>
      <dc:date>2016-03-08T17:04:37Z</dc:date>
    </item>
    <item>
      <title>Re: collapse multiple records into unique one and add column value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/collapse-multiple-records-into-unique-one-and-add-column-value/m-p/255300#M48748</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/68263"&gt;@samnan﻿&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is a data step solution, but the &lt;EM&gt;computation&lt;/EM&gt; could be done using&amp;nbsp;PROC SUMMARY&amp;nbsp;or PROC SQL as well and (unlike the data step) these procedures would not require dataset HAVE to be sorted (or at least grouped) by ID.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
do until(last.id);
  set have;
  by id;
  array type_[5];
  type_[type]=sum(type_[type], value);
  scount=sum(scount, count);
end;
drop type value count;
rename scount=count;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Mar 2016 17:39:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/collapse-multiple-records-into-unique-one-and-add-column-value/m-p/255300#M48748</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-03-08T17:39:57Z</dc:date>
    </item>
    <item>
      <title>Re: collapse multiple records into unique one and add column value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/collapse-multiple-records-into-unique-one-and-add-column-value/m-p/255307#M48750</link>
      <description>&lt;P&gt;thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh﻿&lt;/a&gt;&amp;nbsp;for your help&lt;/P&gt;</description>
      <pubDate>Tue, 08 Mar 2016 17:56:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/collapse-multiple-records-into-unique-one-and-add-column-value/m-p/255307#M48750</guid>
      <dc:creator>samnan</dc:creator>
      <dc:date>2016-03-08T17:56:24Z</dc:date>
    </item>
  </channel>
</rss>

