@Patrick wrote:
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.
@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.
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;
Thank you both. I don't have that many tables so it will work well for me.
@Patrick wrote:
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.
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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.