<?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 a large number of datasets in a library without producing errors in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-a-large-number-of-datasets-in-a-library-without/m-p/798569#M313959</link>
    <description>&lt;P&gt;So PD is pointing to some external database?&lt;/P&gt;
&lt;P&gt;Do the datasets all have the exact some structure? If so then generate 1000 PROC APPEND calls instead.&amp;nbsp; That will only need one database connection per PROC step.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc append data=pd.table1 base=want force;
run;
proc append data=pd.table2 base=want force;
run;
...&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You might also try using pass thru SQL to the remote database.&amp;nbsp; But they probably also will hit limits if we really need to read 1000 tables at once.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Finally you could do it in chunks.&amp;nbsp; Say the limit is 20 table connections.&amp;nbsp; So make 50 temporary datasets from 20 tables each.&amp;nbsp; Then combine the 50 temporary datasets into the target dataset.&lt;/P&gt;</description>
    <pubDate>Fri, 25 Feb 2022 15:16:35 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2022-02-25T15:16:35Z</dc:date>
    <item>
      <title>How to merge a large number of datasets in a library without producing errors</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-a-large-number-of-datasets-in-a-library-without/m-p/798547#M313947</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to merge more than 1000 datasets in a SAS Library into one (All their names start with V if that helps). SAS generates this error when I run my program "&lt;SPAN&gt;ERROR: CLI error trying to establish connection: The permitted number of client connections(510) has been exceeded".&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is the code I use:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc sql noprint;
/* select memname into : names separated by ' ' */
select catx('.',libname,memname)
into :names separated by ' '

from dictionary.tables
where libname='PD';

data want;
set &amp;amp;names;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also used macro and SQL UNION ALL as an alternative, but then there was this error:&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;"ERROR: The text expression length (65538) exceeds maximum length (65534). The text expression has been truncated to 65534 characters."&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I guess the problem is that I have way too many datasets. Can you please help me here? About my level of expertise, I'm just a rookie.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks in advance,&lt;/P&gt;</description>
      <pubDate>Fri, 25 Feb 2022 14:15:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-a-large-number-of-datasets-in-a-library-without/m-p/798547#M313947</guid>
      <dc:creator>sunman</dc:creator>
      <dc:date>2022-02-25T14:15:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge a large number of datasets in a library without producing errors</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-a-large-number-of-datasets-in-a-library-without/m-p/798554#M313954</link>
      <description>&lt;P&gt;Initially, we need to clarify if you want to merge the datasets or append them. The data step you have posted, appends the dataset.&lt;/P&gt;</description>
      <pubDate>Fri, 25 Feb 2022 14:40:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-a-large-number-of-datasets-in-a-library-without/m-p/798554#M313954</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2022-02-25T14:40:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge a large number of datasets in a library without producing errors</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-a-large-number-of-datasets-in-a-library-without/m-p/798563#M313957</link>
      <description>&lt;P&gt;You can use data set lists on a SET statement, so perhaps:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set pd.v: ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That will avoid the problem with the macro variable lengths.&amp;nbsp; You may still get the database multiple connections limit error, I haven't seen that before.&amp;nbsp; There may be an option to increase that limit (either on SAS side, or database side).&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Feb 2022 14:55:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-a-large-number-of-datasets-in-a-library-without/m-p/798563#M313957</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2022-02-25T14:55:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge a large number of datasets in a library without producing errors</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-a-large-number-of-datasets-in-a-library-without/m-p/798566#M313958</link>
      <description>&lt;P&gt;CALL EXECUTE could be a way to get around the restriction on the length of macro variables. However, this would not address the error "&lt;SPAN&gt;The permitted number of client connections(510) has been exceeded". Are these data sets that you are trying to merge in more than 510 different libraries??&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Feb 2022 15:17:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-a-large-number-of-datasets-in-a-library-without/m-p/798566#M313958</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-02-25T15:17:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge a large number of datasets in a library without producing errors</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-a-large-number-of-datasets-in-a-library-without/m-p/798569#M313959</link>
      <description>&lt;P&gt;So PD is pointing to some external database?&lt;/P&gt;
&lt;P&gt;Do the datasets all have the exact some structure? If so then generate 1000 PROC APPEND calls instead.&amp;nbsp; That will only need one database connection per PROC step.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc append data=pd.table1 base=want force;
run;
proc append data=pd.table2 base=want force;
run;
...&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You might also try using pass thru SQL to the remote database.&amp;nbsp; But they probably also will hit limits if we really need to read 1000 tables at once.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Finally you could do it in chunks.&amp;nbsp; Say the limit is 20 table connections.&amp;nbsp; So make 50 temporary datasets from 20 tables each.&amp;nbsp; Then combine the 50 temporary datasets into the target dataset.&lt;/P&gt;</description>
      <pubDate>Fri, 25 Feb 2022 15:16:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-a-large-number-of-datasets-in-a-library-without/m-p/798569#M313959</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-02-25T15:16:35Z</dc:date>
    </item>
  </channel>
</rss>

