Hello,
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 "ERROR: CLI error trying to establish connection: The permitted number of client connections(510) has been exceeded".
Below is the code I use:
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 &names;
run;
I also used macro and SQL UNION ALL as an alternative, but then there was this error:
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.
Many thanks in advance,
Initially, we need to clarify if you want to merge the datasets or append them. The data step you have posted, appends the dataset.
You can use data set lists on a SET statement, so perhaps:
data want;
set pd.v: ;
run;
?
That will avoid the problem with the macro variable lengths. You may still get the database multiple connections limit error, I haven't seen that before. There may be an option to increase that limit (either on SAS side, or database side).
CALL EXECUTE could be a way to get around the restriction on the length of macro variables. However, this would not address the error "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??
So PD is pointing to some external database?
Do the datasets all have the exact some structure? If so then generate 1000 PROC APPEND calls instead. That will only need one database connection per PROC step.
proc append data=pd.table1 base=want force;
run;
proc append data=pd.table2 base=want force;
run;
...
You might also try using pass thru SQL to the remote database. But they probably also will hit limits if we really need to read 1000 tables at once.
Finally you could do it in chunks. Say the limit is 20 table connections. So make 50 temporary datasets from 20 tables each. Then combine the 50 temporary datasets into the target dataset.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.