proc sql join in do loop with macro

872 views Asked by At

I am trying to join over 15 tables and I wrote a macro which has two do loops and the program I wrote is this way.

%macro joinnow (year, Tno); 
%do year=1991 %to 2012; 
%do Tno=2 % to 23; 
Full join A_&year T&Tno ON T1.ID=T&Tno.ID
%End;
%End;
%mend;

Now I run the program

Proc sql; 
create table NEW_tab as 
    Select T1.*, T2.reg_1991,-----,T23.reg_2012
    from  A_1990 T1
    %joinnow; 
; 
Quit; 

I get an error saying

ERROR: Column reg_2002 could not be found in the table/view identified with     the correlation name T13.

where as the reg_2002 is present in T13

Can you see where the error is?

0

There are 0 answers