<?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: How to merge these tables into one? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-these-tables-into-one/m-p/844873#M334006</link>
    <description>&lt;P&gt;Please post the log from the code you ran.&lt;/P&gt;</description>
    <pubDate>Thu, 17 Nov 2022 14:27:16 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2022-11-17T14:27:16Z</dc:date>
    <item>
      <title>How to merge these tables into one?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-these-tables-into-one/m-p/844782#M333975</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I have the following code with me. It outputs 3 tables in the "results" section for each data set. Third table in the "results" section has the names of the variables along with other details such as type, length, etc. I need to combine this third table for each of these data sets so that finally, I just have one table which has the names (and type, length, etc.) of all the variables that are there in all of these tables.&lt;BR /&gt;&lt;BR /&gt;Basically, my goal is to merge all the third tables in the "Results" section so as to get all this information in just one table.&lt;/P&gt;&lt;P&gt;Help would be appreciated. Thank you.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;
libname a meta library="abc" metaout=data;

data list;
     infile datalines4 dlm='|';
    format table $32.;
    input table;
datalines4;
table_a
table_b
table_c
table_d
table_e
table_f
table_g
table_h
;;;;
run;

data _null_;
    set list;
    call execute('
        proc contents data=a.'||strip(table)||';
        run;
    ');
run;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Nov 2022 10:24:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-these-tables-into-one/m-p/844782#M333975</guid>
      <dc:creator>SASuser4321</dc:creator>
      <dc:date>2022-11-17T10:24:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge these tables into one?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-these-tables-into-one/m-p/844783#M333976</link>
      <description>&lt;P&gt;All this information is already available in dictionary.columns and sashelp.cvcolumn metadata tables. No need to jump hoops like this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   set sashelp.vcolumn;
   where libname = 'SASHELP';
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Nov 2022 10:35:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-these-tables-into-one/m-p/844783#M333976</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-11-17T10:35:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge these tables into one?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-these-tables-into-one/m-p/844821#M333990</link>
      <description>I tried something similar but it didn't work for me. What would your code in my case look like exactly? My libname is 'a' and the name of my set is 'list' as is shown in my original post above.&lt;BR /&gt;</description>
      <pubDate>Thu, 17 Nov 2022 12:53:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-these-tables-into-one/m-p/844821#M333990</guid>
      <dc:creator>SASuser4321</dc:creator>
      <dc:date>2022-11-17T12:53:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge these tables into one?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-these-tables-into-one/m-p/844827#M333991</link>
      <description>&lt;P&gt;Sure. See if you can use this as a template. Below, I create 3 data sets for demonstration, table_a, table_b and table_c. I simplify your list data a bit to have those 3 data sets listed. Then I use the dictionary.columns metadata to retrieve information from the tables listed in the list data set.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Obviously, you would have to change the WORK library to A below.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let me know if it works for you &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data table_a; set sashelp.class; run;
data table_b; set sashelp.class; run;
data table_c; set sashelp.class; run;

data list;
     infile datalines4 dlm='|';
    format table $32.;
    input table;
datalines4;
table_a
table_b
table_c
;;;;
run;

proc sql;
   create table want as
   select a.* 
   from dictionary.columns a
      , list b
   where upcase(a.memname) = upcase(b.table)
   and libname = 'WORK'
   ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Nov 2022 13:07:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-these-tables-into-one/m-p/844827#M333991</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-11-17T13:07:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge these tables into one?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-these-tables-into-one/m-p/844861#M334002</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt;&amp;nbsp;, unfortunately it doesn't work for me. Attached with this comment is the picture&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="doesn'twork.PNG" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/77398i36FB41B0E1C021F4/image-size/large?v=v2&amp;amp;px=999" role="button" title="doesn'twork.PNG" alt="doesn'twork.PNG" /&gt;&lt;/span&gt; of what my screen shows me. I appreciate your effort and have upvoted your comments but I was wondering if you know another way to do this, preferably following the line of thought in this:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;data _null_;
    set list;
    call execute('
        proc contents data=a.'||strip(table)||';
        run;
    ');
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Maybe, the code could merge/append as it loops?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Nov 2022 14:23:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-these-tables-into-one/m-p/844861#M334002</guid>
      <dc:creator>SASuser4321</dc:creator>
      <dc:date>2022-11-17T14:23:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge these tables into one?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-these-tables-into-one/m-p/844862#M334003</link>
      <description>&lt;P&gt;What does not work? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Do you get an error or simply different results than what you expect? Please be specific.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Nov 2022 14:20:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-these-tables-into-one/m-p/844862#M334003</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-11-17T14:20:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge these tables into one?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-these-tables-into-one/m-p/844867#M334004</link>
      <description>I edited my above comment and added a picture of what the screen shows me as a result of the code &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Thu, 17 Nov 2022 14:23:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-these-tables-into-one/m-p/844867#M334004</guid>
      <dc:creator>SASuser4321</dc:creator>
      <dc:date>2022-11-17T14:23:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge these tables into one?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-these-tables-into-one/m-p/844873#M334006</link>
      <description>&lt;P&gt;Please post the log from the code you ran.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Nov 2022 14:27:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-these-tables-into-one/m-p/844873#M334006</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-11-17T14:27:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge these tables into one?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-these-tables-into-one/m-p/844880#M334008</link>
      <description>libname a meta library="xyz" metaout=data;&lt;BR /&gt;775 data list;&lt;BR /&gt;776 infile datalines4 dlm='|';&lt;BR /&gt;777 format table $32.;&lt;BR /&gt;778 input table;&lt;BR /&gt;779 datalines4;&lt;BR /&gt;&lt;BR /&gt;NOTE: The data set WORK.LIST has 28 observations and 1 variables.&lt;BR /&gt;NOTE: Compressing data set WORK.LIST increased size by 100.00 percent.&lt;BR /&gt;Compressed is 2 pages; un-compressed would require 1 pages.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.00 seconds&lt;BR /&gt;cpu time 0.00 seconds&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;808 ;;;;&lt;BR /&gt;809 run;&lt;BR /&gt;810&lt;BR /&gt;811 proc sql;&lt;BR /&gt;812 create table want as&lt;BR /&gt;813 select a.*&lt;BR /&gt;814 from dictionary.columns a&lt;BR /&gt;815 , list b&lt;BR /&gt;816 where upcase(a.memname) = upcase(b.table)&lt;BR /&gt;817 and libname = 'a'&lt;BR /&gt;818 ;&lt;BR /&gt;NOTE: Table WORK.WANT created, with 0 rows and 18 columns.&lt;BR /&gt;&lt;BR /&gt;819 quit;&lt;BR /&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;BR /&gt;real time 0.00 seconds&lt;BR /&gt;cpu time 0.00 seconds&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;820&lt;BR /&gt;821 GOPTIONS NOACCESSIBLE;&lt;BR /&gt;822 %LET _CLIENTTASKLABEL=;&lt;BR /&gt;823 %LET _CLIENTPROCESSFLOWNAME=;&lt;BR /&gt;824 %LET _CLIENTPROJECTPATH=;&lt;BR /&gt;825 %LET _CLIENTPROJECTPATHHOST=;&lt;BR /&gt;826 %LET _CLIENTPROJECTNAME=;&lt;BR /&gt;827 %LET _SASPROGRAMFILE=;&lt;BR /&gt;828 %LET _SASPROGRAMFILEHOST=;&lt;BR /&gt;829&lt;BR /&gt;830 ;*';*";*/;quit;run;&lt;BR /&gt;831 ODS _ALL_ CLOSE;&lt;BR /&gt;3 The SAS System Thursday, November 17, 2022&lt;BR /&gt;&lt;BR /&gt;832&lt;BR /&gt;833&lt;BR /&gt;834 QUIT; RUN;&lt;BR /&gt;835 %_eg_gridremoteepilogue;&lt;BR /&gt;836 %sysrput _EGRCGRID=&amp;amp;_EGRC;&lt;BR /&gt;NOTE: Remote submit to GRID complete.&lt;BR /&gt;2 %_eg_gridclientepilogue;&lt;BR /&gt;3 %let _EGRC=&amp;amp;_EGRCGRID;&lt;BR /&gt;4&lt;BR /&gt;</description>
      <pubDate>Thu, 17 Nov 2022 14:34:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-these-tables-into-one/m-p/844880#M334008</guid>
      <dc:creator>SASuser4321</dc:creator>
      <dc:date>2022-11-17T14:34:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge these tables into one?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-these-tables-into-one/m-p/844882#M334009</link>
      <description>&lt;P&gt;The 'a' should be a capital 'A' in the code.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Nov 2022 14:43:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-these-tables-into-one/m-p/844882#M334009</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-11-17T14:43:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge these tables into one?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-these-tables-into-one/m-p/844887#M334014</link>
      <description>&lt;P&gt;If all you care about is to get a list of variables present in at least one of the datasets, then just make an empty dataset of all the component datasets, and run a proc contents:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dummy;
  set a.table_a
      a.table_b
      a.table_c
      a.table_d
      a.table_e
      a.table_f
      a.table_g
      a.table_h ;
  stop;
run;
proc contents data=dummy; 
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note the "stop:" statement tells the data step to stop, even before the first observation is processed.&amp;nbsp; So no excess input/output is performed. But it will write out the header. So you'll have zero obs, but all the variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note this assumes that any common variable will be either numeric in every instance, or character in every instance.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Nov 2022 14:55:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-these-tables-into-one/m-p/844887#M334014</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2022-11-17T14:55:36Z</dc:date>
    </item>
  </channel>
</rss>

