<?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 SAS Vertical Merge in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/SAS-Vertical-Merge/m-p/700724#M79851</link>
    <description>&lt;P&gt;I have three tables and I want to vertically merge those tables&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Table A&lt;/P&gt;&lt;P&gt;Name&amp;nbsp; Money&amp;nbsp;&lt;/P&gt;&lt;P&gt;X&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2000&lt;/P&gt;&lt;P&gt;Y&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 4000&lt;/P&gt;&lt;P&gt;Table B&lt;/P&gt;&lt;P&gt;Name&amp;nbsp; Money&lt;/P&gt;&lt;P&gt;X&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 600&lt;/P&gt;&lt;P&gt;Z&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 400&lt;/P&gt;&lt;P&gt;Table C&lt;/P&gt;&lt;P&gt;Name Money&lt;/P&gt;&lt;P&gt;Y&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;8000&lt;/P&gt;&lt;P&gt;Z&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 600&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to combine these tables into single table like this using&amp;nbsp; proc sql so that I can save the table:&lt;/P&gt;&lt;P&gt;Name Money_1 Money_2 Money_3&lt;/P&gt;&lt;P&gt;X&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;600&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&lt;/P&gt;&lt;P&gt;Y&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;4000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;8000&lt;/P&gt;&lt;P&gt;Z&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 400&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 600&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Like this I have 50 tables and I want to merge them vertically using proc sql&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;One solution is&amp;nbsp; joining two tables at once using full join but in select statement choose the Name variable of table with the most rows. That works for few tables but i have over 50 tables and I need a feasible solution to this problem&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 22 Nov 2020 03:47:17 GMT</pubDate>
    <dc:creator>arjunaj91</dc:creator>
    <dc:date>2020-11-22T03:47:17Z</dc:date>
    <item>
      <title>SAS Vertical Merge</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SAS-Vertical-Merge/m-p/700724#M79851</link>
      <description>&lt;P&gt;I have three tables and I want to vertically merge those tables&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Table A&lt;/P&gt;&lt;P&gt;Name&amp;nbsp; Money&amp;nbsp;&lt;/P&gt;&lt;P&gt;X&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2000&lt;/P&gt;&lt;P&gt;Y&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 4000&lt;/P&gt;&lt;P&gt;Table B&lt;/P&gt;&lt;P&gt;Name&amp;nbsp; Money&lt;/P&gt;&lt;P&gt;X&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 600&lt;/P&gt;&lt;P&gt;Z&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 400&lt;/P&gt;&lt;P&gt;Table C&lt;/P&gt;&lt;P&gt;Name Money&lt;/P&gt;&lt;P&gt;Y&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;8000&lt;/P&gt;&lt;P&gt;Z&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 600&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to combine these tables into single table like this using&amp;nbsp; proc sql so that I can save the table:&lt;/P&gt;&lt;P&gt;Name Money_1 Money_2 Money_3&lt;/P&gt;&lt;P&gt;X&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;600&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&lt;/P&gt;&lt;P&gt;Y&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;4000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;8000&lt;/P&gt;&lt;P&gt;Z&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 400&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 600&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Like this I have 50 tables and I want to merge them vertically using proc sql&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;One solution is&amp;nbsp; joining two tables at once using full join but in select statement choose the Name variable of table with the most rows. That works for few tables but i have over 50 tables and I need a feasible solution to this problem&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 22 Nov 2020 03:47:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SAS-Vertical-Merge/m-p/700724#M79851</guid>
      <dc:creator>arjunaj91</dc:creator>
      <dc:date>2020-11-22T03:47:17Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Vertical Merge</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SAS-Vertical-Merge/m-p/700726#M79852</link>
      <description>&lt;P&gt;There is no "vertical merge". You can either stack datasets vertically, or join/merge them horizontally.&lt;/P&gt;
&lt;P&gt;What you want can be most simply achieved by first stacking, with an interleave, and then transposing:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data long;
length dname $41 dsname $32;
set
  table_a
  table_b
  table_c
  indsname=dname
;
by name;
dsname = scan(dname,2,"."); /* removes library name */
run;

proc transpose
  data=long
  out=want
;
by name;
var money;
id dsname;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;With additional logic in the data step, you can create variable names for the transpose to your liking.&lt;/P&gt;
&lt;P&gt;The only thing that should be automated is the list of dataset names for the SET statement. You can use a colon wildcard there (lib.table:), or retrieve the list from DICTIONARY.TABLES in SQL into a macro variable.&lt;/P&gt;</description>
      <pubDate>Sun, 22 Nov 2020 04:58:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SAS-Vertical-Merge/m-p/700726#M79852</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-11-22T04:58:34Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Vertical Merge</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SAS-Vertical-Merge/m-p/700728#M79853</link>
      <description>&lt;P&gt;I would just leave it in a tall structure.&amp;nbsp; You can then produce that report using a reporting procedure like PROC REPORT, TABLULATE or FREQ.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data tall;
  length indsname dsname $41 ;
  set A B C indsname=indsname;
  by name;
  dsname=indsname;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;Obs    dsname    Name    Money

 1     WORK.A     X       2000
 2     WORK.B     X        600
 3     WORK.A     Y       4000
 4     WORK.C     Y       8000
 5     WORK.B     Z        400
 6     WORK.C     Z        600
&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq ;
 tables name*dsname;
 weight money ;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 22 Nov 2020 05:15:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SAS-Vertical-Merge/m-p/700728#M79853</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-11-22T05:15:14Z</dc:date>
    </item>
  </channel>
</rss>

