I want to join 6 tables, which all have different variables, to one table, which has same columns as all 6 other tables. Can i somehow do it without looking at these tables and watching which columns these tables have? I have got macro variable, an array, with column names, but I cannot think of any good way how to join these tables using this array.
Array is created by this macro:
%macro getvars(dsn);
%global vlist;
proc sql noprint;
select name into :vlist separated by ' '
from dictionary.columns
where memname=upcase("&dsn");
quit;
%mend getvars;
And i want to just join tables like this:
proc sql;
create table new_table as select * from table1 as l
left join table2 as r on l.age=r.age and l.type=r.type;
quit;
but not so manually :)
For example, table1 has columns name, age, coef1 and sex, table 2 has columns name, region and coef2. The third table, where I want to join them has name, age, sex, region, coef and many other columns. I want to write a program, that doesn't know which table has which columns, but joins so that third table still has all the same columns plus coef1 and coef2.