<?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: aggregate by column and paste row values together in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/aggregate-by-column-and-paste-row-values-together/m-p/200194#M49991</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Same as PG.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;
data test;
&amp;nbsp;&amp;nbsp; input a b c d e f g h i j k l;
&amp;nbsp;&amp;nbsp; datalines;
1 0 0 0 0 1 0 0 1 0 0 0
0 1 0 0 0 0 1 0 0 1 0 0
0 0 1 0 1 0 0 0 1 0 0 0
0 0 0 1 0 0 0 1 0 0 1 0
;
run;

%let dsid=%sysfunc(open(test));
%let nvar=%sysfunc(attrn(&amp;amp;dsid,nvar));
%let dsid=%sysfunc(close(&amp;amp;dsid));
data temp;
 set test;
 array _x{*} _numeric_;
 array _y{*} $ __1-__%eval(&amp;amp;nvar/4); 
 _n=0;
 do _n_=1 to dim(_x) by 4; 
&amp;nbsp; _n+1;
&amp;nbsp; _y(_n)=cats(_x{_n_},_x{_n_+1},_x{_n_+2},_x{_n_+3});
 end;
 keep __:;
run;
proc transpose data=temp out=want;
var _all_;
run;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Xia Keshan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 21 Apr 2015 13:32:02 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2015-04-21T13:32:02Z</dc:date>
    <item>
      <title>aggregate by column and paste row values together</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/aggregate-by-column-and-paste-row-values-together/m-p/200189#M49986</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;STRONG&gt;Have:&lt;/STRONG&gt; &lt;/P&gt;&lt;P&gt;data test;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; input a b c d e f g h i j k l;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; datalines;&lt;/P&gt;&lt;P&gt;1 0 0 0 0 1 0 0 1 0 0 0&lt;/P&gt;&lt;P&gt;0 1 0 0 0 0 1 0 0 1 0 0&lt;/P&gt;&lt;P&gt;0 0 1 0 1 0 0 0 1 0 0 0&lt;/P&gt;&lt;P&gt;0 0 0 1 0 0 0 1 0 0 1 0&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;WANT:&lt;/STRONG&gt; &lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" width="320"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl65" height="20" width="64"&gt;block&lt;/TD&gt;&lt;TD class="xl65" style="border-left: none;" width="64"&gt;col1&lt;/TD&gt;&lt;TD class="xl65" style="border-left: none;" width="64"&gt;col2&lt;/TD&gt;&lt;TD class="xl65" style="border-left: none;" width="64"&gt;col3&lt;/TD&gt;&lt;TD class="xl65" style="border-left: none;" width="64"&gt;col4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl65" height="20" style="border-top: none;"&gt;1&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt;1000&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt;0100&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt;0010&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt;0001&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl65" height="20" style="border-top: none;"&gt;2&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt;0100&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt;0010&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt;1000&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt;0001&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl65" height="20" style="border-top: none;"&gt;3&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt;1000&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt;0100&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt;1000&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt;0010&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Here's what I tried:&lt;/STRONG&gt; &lt;/P&gt;&lt;P&gt;proc transpose data = have out = test_t;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data test_t;&lt;/P&gt;&lt;P&gt;set test_t;&lt;/P&gt;&lt;P&gt;retain block;&lt;/P&gt;&lt;P&gt;if _n_ = 1 then block = 1;&lt;/P&gt;&lt;P&gt;if mod(_n_/4,1) = 0.25 and _n_ gt 1 then block +1;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This gives me:&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl63" height="20" style="border: 0px solid black;" width="64"&gt;Name&lt;/TD&gt;&lt;TD class="xl63" style="border: 0px solid black; border-left: none;" width="64"&gt;Col1&lt;/TD&gt;&lt;TD class="xl63" style="border: 0px solid black; border-left: none;" width="64"&gt;Col2&lt;/TD&gt;&lt;TD class="xl63" style="border: 0px solid black; border-left: none;" width="64"&gt;Col3&lt;/TD&gt;&lt;TD class="xl63" style="border: 0px solid black; border-left: none;" width="64"&gt;Col4&lt;/TD&gt;&lt;TD class="xl63" style="border: 0px solid black; border-left: none;" width="64"&gt;block&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="20" style="border: 0px solid black; border-top: none;"&gt;a&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border: 0px solid black; border-left: none; border-top: none;"&gt;1&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border: 0px solid black; border-left: none; border-top: none;"&gt;0&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border: 0px solid black; border-left: none; border-top: none;"&gt;0&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border: 0px solid black; border-left: none; border-top: none;"&gt;0&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border: 0px solid black; border-left: none; border-top: none;"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="20" style="border: 0px solid black; border-top: none;"&gt;b&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border: 0px solid black; border-left: none; border-top: none;"&gt;0&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border: 0px solid black; border-left: none; border-top: none;"&gt;1&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border: 0px solid black; border-left: none; border-top: none;"&gt;0&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border: 0px solid black; border-left: none; border-top: none;"&gt;0&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border: 0px solid black; border-left: none; border-top: none;"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="20" style="border: 0px solid black; border-top: none;"&gt;c&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border: 0px solid black; border-left: none; border-top: none;"&gt;0&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border: 0px solid black; border-left: none; border-top: none;"&gt;0&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border: 0px solid black; border-left: none; border-top: none;"&gt;1&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border: 0px solid black; border-left: none; border-top: none;"&gt;0&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border: 0px solid black; border-left: none; border-top: none;"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="20" style="border: 0px solid black; border-top: none;"&gt;d&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border: 0px solid black; border-left: none; border-top: none;"&gt;0&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border: 0px solid black; border-left: none; border-top: none;"&gt;0&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border: 0px solid black; border-left: none; border-top: none;"&gt;0&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border: 0px solid black; border-left: none; border-top: none;"&gt;1&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border: 0px solid black; border-left: none; border-top: none;"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="20" style="border: 0px solid black; border-top: none;"&gt;e&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border: 0px solid black; border-left: none; border-top: none;"&gt;0&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border: 0px solid black; border-left: none; border-top: none;"&gt;0&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border: 0px solid black; border-left: none; border-top: none;"&gt;1&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border: 0px solid black; border-left: none; border-top: none;"&gt;0&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border: 0px solid black; border-left: none; border-top: none;"&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="20" style="border: 0px solid black; border-top: none;"&gt;f&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border: 0px solid black; border-left: none; border-top: none;"&gt;1&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border: 0px solid black; border-left: none; border-top: none;"&gt;0&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border: 0px solid black; border-left: none; border-top: none;"&gt;0&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border: 0px solid black; border-left: none; border-top: none;"&gt;0&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border: 0px solid black; border-left: none; border-top: none;"&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="20" style="border: 0px solid black; border-top: none;"&gt;g&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border: 0px solid black; border-left: none; border-top: none;"&gt;0&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border: 0px solid black; border-left: none; border-top: none;"&gt;1&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border: 0px solid black; border-left: none; border-top: none;"&gt;0&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border: 0px solid black; border-left: none; border-top: none;"&gt;0&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border: 0px solid black; border-left: none; border-top: none;"&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="20" style="border: 0px solid black; border-top: none;"&gt;h&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border: 0px solid black; border-left: none; border-top: none;"&gt;0&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border: 0px solid black; border-left: none; border-top: none;"&gt;0&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border: 0px solid black; border-left: none; border-top: none;"&gt;0&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border: 0px solid black; border-left: none; border-top: none;"&gt;1&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border: 0px solid black; border-left: none; border-top: none;"&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="20" style="border: 0px solid black; border-top: none;"&gt;i&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border: 0px solid black; border-left: none; border-top: none;"&gt;1&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border: 0px solid black; border-left: none; border-top: none;"&gt;0&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border: 0px solid black; border-left: none; border-top: none;"&gt;1&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border: 0px solid black; border-left: none; border-top: none;"&gt;0&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border: 0px solid black; border-left: none; border-top: none;"&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="20" style="border: 0px solid black; border-top: none;"&gt;j&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border: 0px solid black; border-left: none; border-top: none;"&gt;0&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border: 0px solid black; border-left: none; border-top: none;"&gt;1&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border: 0px solid black; border-left: none; border-top: none;"&gt;0&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border: 0px solid black; border-left: none; border-top: none;"&gt;0&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border: 0px solid black; border-left: none; border-top: none;"&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="20" style="border: 0px solid black; border-top: none;"&gt;k&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border: 0px solid black; border-left: none; border-top: none;"&gt;0&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border: 0px solid black; border-left: none; border-top: none;"&gt;0&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border: 0px solid black; border-left: none; border-top: none;"&gt;0&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border: 0px solid black; border-left: none; border-top: none;"&gt;1&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border: 0px solid black; border-left: none; border-top: none;"&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="20" style="border: 0px solid black; border-top: none;"&gt;l&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border: 0px solid black; border-left: none; border-top: none;"&gt;0&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border: 0px solid black; border-left: none; border-top: none;"&gt;0&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border: 0px solid black; border-left: none; border-top: none;"&gt;0&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border: 0px solid black; border-left: none; border-top: none;"&gt;0&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border: 0px solid black; border-left: none; border-top: none;"&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there a way I can group this / aggregate by "block" to get something like :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="width: 320px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl65" height="20" style="border: 0px solid black;" width="64"&gt;block&lt;/TD&gt;&lt;TD class="xl65" style="border: 0px solid black; border-left: none;" width="64"&gt;col1&lt;/TD&gt;&lt;TD class="xl65" style="border: 0px solid black; border-left: none;" width="64"&gt;col2&lt;/TD&gt;&lt;TD class="xl65" style="border: 0px solid black; border-left: none;" width="64"&gt;col3&lt;/TD&gt;&lt;TD class="xl65" style="border: 0px solid black; border-left: none;" width="64"&gt;col4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl65" height="20" style="border: 0px solid black; border-top: none;"&gt;1&lt;/TD&gt;&lt;TD class="xl66" style="border: 0px solid black; border-left: none; border-top: none;"&gt;1000&lt;/TD&gt;&lt;TD class="xl66" style="border: 0px solid black; border-left: none; border-top: none;"&gt;0100&lt;/TD&gt;&lt;TD class="xl66" style="border: 0px solid black; border-left: none; border-top: none;"&gt;0010&lt;/TD&gt;&lt;TD class="xl66" style="border: 0px solid black; border-left: none; border-top: none;"&gt;0001&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl65" height="20" style="border: 0px solid black; border-top: none;"&gt;2&lt;/TD&gt;&lt;TD class="xl66" style="border: 0px solid black; border-left: none; border-top: none;"&gt;0100&lt;/TD&gt;&lt;TD class="xl66" style="border: 0px solid black; border-left: none; border-top: none;"&gt;0010&lt;/TD&gt;&lt;TD class="xl66" style="border: 0px solid black; border-left: none; border-top: none;"&gt;1000&lt;/TD&gt;&lt;TD class="xl66" style="border: 0px solid black; border-left: none; border-top: none;"&gt;0001&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl65" height="20" style="border: 0px solid black; border-top: none;"&gt;3&lt;/TD&gt;&lt;TD class="xl66" style="border: 0px solid black; border-left: none; border-top: none;"&gt;1000&lt;/TD&gt;&lt;TD class="xl66" style="border: 0px solid black; border-left: none; border-top: none;"&gt;0100&lt;/TD&gt;&lt;TD class="xl66" style="border: 0px solid black; border-left: none; border-top: none;"&gt;1000&lt;/TD&gt;&lt;TD class="xl66" style="border: 0px solid black; border-left: none; border-top: none;"&gt;0010&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Apr 2015 17:12:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/aggregate-by-column-and-paste-row-values-together/m-p/200189#M49986</guid>
      <dc:creator>ngnikhilgoyal</dc:creator>
      <dc:date>2015-04-20T17:12:37Z</dc:date>
    </item>
    <item>
      <title>Re: aggregate by column and paste row values together</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/aggregate-by-column-and-paste-row-values-together/m-p/200190#M49987</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is one way to play:&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; test;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;input&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; (a b c d e f g h i j k l) (:&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: teal; background: white;"&gt;$1.&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;datalines&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;1 0 0 0 0 1 0 0 1 0 0 0&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;0 1 0 0 0 0 1 0 0 1 0 0&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;0 0 1 0 1 0 0 0 1 0 0 0&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;0 0 0 1 0 0 0 1 0 0 1 0&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;proc&lt;/STRONG&gt; &lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;sql&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;select&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; CEIL(NVAR/&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-family: 'Courier New';"&gt;4&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;) &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;into&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; :new trimmed &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;from&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; dictionary.tables &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;where&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; libname=&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: purple; background: white;"&gt;'WORK'&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;and&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; memname=&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: purple; background: white;"&gt;'TEST'&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;QUIT&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; test1(&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;keep&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;=_:);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; test;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;array&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; old(*) a--l;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;array&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; new(*) $ &lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-family: 'Courier New';"&gt;4&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; _1-_&amp;amp;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: teal; background: white;"&gt;new.&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;call&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; pokelong(peekclong(addrlong(old(&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;)),dim(old)), addrlong(new(&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;)),dim(old));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;proc&lt;/STRONG&gt; &lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;transpose&lt;/STRONG&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;data&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; = test1 &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;out&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; = want(&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;rename&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;=(_name_=Block));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;var&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; _:;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Apr 2015 18:23:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/aggregate-by-column-and-paste-row-values-together/m-p/200190#M49987</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2015-04-20T18:23:59Z</dc:date>
    </item>
    <item>
      <title>Re: aggregate by column and paste row values together</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/aggregate-by-column-and-paste-row-values-together/m-p/200191#M49988</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You were close :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data test;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; input a b c d e f g h i j k l;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; datalines;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;1 0 0 0 0 1 0 0 1 0 0 0&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;0 1 0 0 0 0 1 0 0 1 0 0&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;0 0 1 0 1 0 0 0 1 0 0 0&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;0 0 0 1 0 0 0 1 0 0 1 0&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc transpose data=test out=testt(drop=_:); run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data want;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;block + 1;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;array f{4} $8;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;do i = 1 to dim(f);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set testt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; f{i} = cats(of col:);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;output;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;keep block f:;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc print data=want noobs; run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Apr 2015 18:28:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/aggregate-by-column-and-paste-row-values-together/m-p/200191#M49988</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2015-04-20T18:28:11Z</dc:date>
    </item>
    <item>
      <title>Re: aggregate by column and paste row values together</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/aggregate-by-column-and-paste-row-values-together/m-p/200192#M49989</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;A __default_attr="2746" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For some reason some of your output values in the want table are not consistent with the input table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" width="320"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD height="20" width="64"&gt;block&lt;/TD&gt;&lt;TD width="64"&gt;f1&lt;/TD&gt;&lt;TD width="64"&gt;f2&lt;/TD&gt;&lt;TD width="64"&gt;f3&lt;/TD&gt;&lt;TD width="64"&gt;f4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" height="20"&gt;1&lt;/TD&gt;&lt;TD class="xl65"&gt;1000&lt;/TD&gt;&lt;TD class="xl65"&gt;0100&lt;/TD&gt;&lt;TD class="xl65"&gt;0010&lt;/TD&gt;&lt;TD class="xl65"&gt;0001&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" height="20"&gt;2&lt;/TD&gt;&lt;TD class="xl65"&gt;0010&lt;/TD&gt;&lt;TD class="xl65"&gt;1000&lt;/TD&gt;&lt;TD class="xl65"&gt;0100&lt;/TD&gt;&lt;TD class="xl65"&gt;0001&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" height="20"&gt;3&lt;/TD&gt;&lt;TD class="xl65"&gt;1010&lt;/TD&gt;&lt;TD class="xl65"&gt;0100&lt;/TD&gt;&lt;TD class="xl65"&gt;0001&lt;/TD&gt;&lt;TD class="xl65"&gt;0000&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Correct output: &lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" width="320"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl65" height="20" width="64"&gt;block&lt;/TD&gt;&lt;TD class="xl65" style="border-left: none;" width="64"&gt;col1&lt;/TD&gt;&lt;TD class="xl65" style="border-left: none;" width="64"&gt;col2&lt;/TD&gt;&lt;TD class="xl65" style="border-left: none;" width="64"&gt;col3&lt;/TD&gt;&lt;TD class="xl65" style="border-left: none;" width="64"&gt;col4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl65" height="20" style="border-top: none;"&gt;1&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt;1000&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt;0100&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt;0010&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt;0001&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl65" height="20" style="border-top: none;"&gt;2&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt;0100&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt;0010&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt;1000&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt;0001&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl65" height="20" style="border-top: none;"&gt;3&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt;1000&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt;0100&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt;1000&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;"&gt;0010&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Apr 2015 19:14:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/aggregate-by-column-and-paste-row-values-together/m-p/200192#M49989</guid>
      <dc:creator>ngnikhilgoyal</dc:creator>
      <dc:date>2015-04-20T19:14:38Z</dc:date>
    </item>
    <item>
      <title>Re: aggregate by column and paste row values together</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/aggregate-by-column-and-paste-row-values-together/m-p/200193#M49990</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry, I misunderstood. Here is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data test;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; input a b c d e f g h i j k l;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; datalines;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;1 0 0 0 0 1 0 0 1 0 0 0&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;0 1 0 0 0 0 1 0 0 1 0 0&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;0 0 1 0 1 0 0 0 1 0 0 0&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;0 0 0 1 0 0 0 1 0 0 1 0&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data temp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;length bblock $24;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;set test;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;array block{3} $8;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;bblock = cats(of _numeric_);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;do bb = 1 to dim(block);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; block{bb}= substr(bblock, 4*bb-3, 4);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;cc + 1;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;col = cats("Col", cc);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;keep block: col;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc transpose data=temp out=want name=block;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;id col;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;var block:;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc print data=want noobs; run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Apr 2015 21:19:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/aggregate-by-column-and-paste-row-values-together/m-p/200193#M49990</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2015-04-20T21:19:16Z</dc:date>
    </item>
    <item>
      <title>Re: aggregate by column and paste row values together</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/aggregate-by-column-and-paste-row-values-together/m-p/200194#M49991</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Same as PG.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;
data test;
&amp;nbsp;&amp;nbsp; input a b c d e f g h i j k l;
&amp;nbsp;&amp;nbsp; datalines;
1 0 0 0 0 1 0 0 1 0 0 0
0 1 0 0 0 0 1 0 0 1 0 0
0 0 1 0 1 0 0 0 1 0 0 0
0 0 0 1 0 0 0 1 0 0 1 0
;
run;

%let dsid=%sysfunc(open(test));
%let nvar=%sysfunc(attrn(&amp;amp;dsid,nvar));
%let dsid=%sysfunc(close(&amp;amp;dsid));
data temp;
 set test;
 array _x{*} _numeric_;
 array _y{*} $ __1-__%eval(&amp;amp;nvar/4); 
 _n=0;
 do _n_=1 to dim(_x) by 4; 
&amp;nbsp; _n+1;
&amp;nbsp; _y(_n)=cats(_x{_n_},_x{_n_+1},_x{_n_+2},_x{_n_+3});
 end;
 keep __:;
run;
proc transpose data=temp out=want;
var _all_;
run;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Xia Keshan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Apr 2015 13:32:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/aggregate-by-column-and-paste-row-values-together/m-p/200194#M49991</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2015-04-21T13:32:02Z</dc:date>
    </item>
  </channel>
</rss>

