<?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: Merge all datasets in library (not work) in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Merge-all-datasets-in-library-not-work/m-p/569462#M11822</link>
    <description>&lt;P&gt;When generating code first think about what code you want to generate.&lt;/P&gt;
&lt;P&gt;In your case you want something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;merge CAPA.table1 CAPA.table2 ...&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So obviously you are not going to get that by selection only the MEMNAME value from the metadata. You need to take the LIBNAME value also.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select catx('.',libname,memname)
  into :names separated by ' '&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 27 Jun 2019 14:46:00 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2019-06-27T14:46:00Z</dc:date>
    <item>
      <title>Merge all datasets in library (not work)</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Merge-all-datasets-in-library-not-work/m-p/569452#M11820</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm referencing to this topic: (which is solved and no reply is possible)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/Merge-all-datasets-in-library/td-p/97413" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/Merge-all-datasets-in-library/td-p/97413&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The original question was:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have 15 datasets in a library. the data is already sorted. is there a way to merge them all together with out having to write each one out?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The accepted solution was:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
   select memname into : names &lt;SPAN style="font-size: 12pt;"&gt;&lt;STRONG style="color: #ff0000;"&gt;separated by '&amp;nbsp; '&lt;/STRONG&gt;&lt;/SPAN&gt;
     from dictionary.tables
    where libname='WORK'; /* note: libname must be in upcase */
data want;
   merge &amp;amp;names;
   by name;
  run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;H2 class="lia-thread-subject"&gt;&lt;FONT size="2"&gt;This all works fine when the tables are in WORK.&lt;/FONT&gt;&lt;/H2&gt;
&lt;P&gt;&lt;FONT size="2"&gt;My situation is different:&amp;nbsp; all tables ( &amp;gt; 50) have the same layout and are in libname CAPA.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;So I've edited this code to:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
   select memname into : names separated by '  '
     from dictionary.tables
       where libname='&lt;STRONG&gt;CAPA&lt;/STRONG&gt;'; /* note: libname must be in upcase */

data want;
   set &amp;amp;names;
 run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;When I look to the value of &lt;STRONG&gt;names, &lt;/STRONG&gt;it shows a string of all the 50 tables, but without the libname.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;What I need is the following string, with libname in front of each table:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;&lt;EM&gt;CAPA.table1 CAPA.table2 CAPA.table3 ...&amp;nbsp; CAPA.table50&amp;nbsp;&amp;nbsp;&lt;/EM&gt; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;instead of:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;&lt;EM&gt;table1 table2 table3 ... table50&amp;nbsp;&lt;/EM&gt; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;Is this possible?&lt;/FONT&gt;&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>Thu, 27 Jun 2019 14:35:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Merge-all-datasets-in-library-not-work/m-p/569452#M11820</guid>
      <dc:creator>fre</dc:creator>
      <dc:date>2019-06-27T14:35:55Z</dc:date>
    </item>
    <item>
      <title>Re: Merge all datasets in library (not work)</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Merge-all-datasets-in-library-not-work/m-p/569461#M11821</link>
      <description>select catx(".", "CAPA", memname) into : names separated by ......&lt;BR /&gt;&lt;BR /&gt;USE the CATX() function to create the correct variable in the query.</description>
      <pubDate>Thu, 27 Jun 2019 14:43:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Merge-all-datasets-in-library-not-work/m-p/569461#M11821</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-06-27T14:43:10Z</dc:date>
    </item>
    <item>
      <title>Re: Merge all datasets in library (not work)</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Merge-all-datasets-in-library-not-work/m-p/569462#M11822</link>
      <description>&lt;P&gt;When generating code first think about what code you want to generate.&lt;/P&gt;
&lt;P&gt;In your case you want something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;merge CAPA.table1 CAPA.table2 ...&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So obviously you are not going to get that by selection only the MEMNAME value from the metadata. You need to take the LIBNAME value also.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select catx('.',libname,memname)
  into :names separated by ' '&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 27 Jun 2019 14:46:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Merge-all-datasets-in-library-not-work/m-p/569462#M11822</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-06-27T14:46:00Z</dc:date>
    </item>
    <item>
      <title>Re: Merge all datasets in library (not work)</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Merge-all-datasets-in-library-not-work/m-p/569603#M11838</link>
      <description>&lt;P&gt;Thank you Tom &amp;amp; Reeza, it works like it should now.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jun 2019 19:40:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Merge-all-datasets-in-library-not-work/m-p/569603#M11838</guid>
      <dc:creator>fre</dc:creator>
      <dc:date>2019-06-27T19:40:08Z</dc:date>
    </item>
  </channel>
</rss>

