BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Tom
Super User Tom
Super User

@Patrick wrote:

@ScottBass 

Using an OUTER UNION CORR as @FreelanceReinh proposes is such a simple approach for "length alignment".

Why would you want to replace that with any other coding option if there aren't additional requirements you need to address?


There used to be a limit to how many tables you could reference in a single PROC SQL statement.  I seem to remember the limit was in the order of 15 to 20 tables.  Not sure if that has been relaxed.

Patrick
Opal | Level 21

@Tom wrote:

There used to be a limit to how many tables you could reference in a single PROC SQL statement.  I seem to remember the limit was in the order of 15 to 20 tables.  Not sure if that has been relaxed.

@Tom

Just tried. The limit for a recent SAS version appears to be 256 tables. Below the error if you exceed that limit.

ERROR: A maximum of 256 tables can be processed in a single PROC SQL statement.

 

Test code used:

%let n_tables=256;
filename codegen temp;
data _null_;
  file codegen;
  if 0 then set sashelp.class;
  dcl hash h1(dataset:'sashelp.class(obs=5)');
  h1.defineKey('name');
  h1.defineData(all:'y');
  h1.defineDone();

  put "proc sql nowarn inobs=0;";
  put "create table mapping as";
  do i=1 to &n_tables;
    h1.output(dataset:'have_'||put(i,z4.));
    put 'select * from have_' i z4.;
    if i<&n_tables then put 'outer union corr';
  end;
  put "; quit;";
  stop;
run;
%include codegen / source2;
filename codegen clear;
Mscarboncopy
Pyrite | Level 9

Thank you both. I don't have that many tables so it will work well for me. 

 

ScottBass
Rhodochrosite | Level 12

@Patrick wrote:

@ScottBass 

Using an OUTER UNION CORR as @FreelanceReinh proposes is such a simple approach for "length alignment".

I agree.

Why would you want to replace that with any other coding option if there aren't additional requirements you need to address?

I dunno.  A momentary lapse of judgement?  I had in mind that PROC SQL had a lower limit on the number of tables, thanks for clarifying that.

 

Perhaps my approach can be tweaked for a different problem in the future, should someone find this thread.  But for the problem as stated, I agree with the accepted solution.


 


Please post your question as a self-contained data step in the form of "have" (source) and "want" (desired results).
I won't contribute to your post if I can't cut-and-paste your syntactically correct code into SAS.
Mscarboncopy
Pyrite | Level 9

I appreciate your help and apologize for not having the data step. I did use the first solution proposed on this thread and it worked for what I needed to do. I will definitely keep your idea, if I ever need it. Thank you.

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 19 replies
  • 7955 views
  • 17 likes
  • 8 in conversation