Dear @Kurt_Bremser Your code works well. But I have a little issue, Once I tried your method with replacement by my tables it performed well, but on few tables it cause ERROR. %macro aaa(lu,Tab1,Tab2);
proc sql;
create table &lu as
select a.Student_id
from &Tab1 a inner join &Tab2 b
on a.Student_id = b.Student_id
;
insert into &Tab1
select * from &Tab2 a
where a.Student_id not in (select Student_id from &lu)
;
quit;
%mend;
%aaa (reg1,S0.School1,S2.School2);
%aaa (reg2,S0.School1,S3.School3);
%aaa (reg3,S0.School1,S4.School4); For the First Macro line 88 %aaa( reg1 , S0.School1 , S2.School2 ); NOTE: Table WORK.REG1 created, with 132489 rows and 1 columns. NOTE: 55148 row was inserted into S0.School1 /*************************************************************/ 88 %aaa( reg2 , S0.School1 , S3.School3 ); NOTE: Table WORK.REG2 created, with 456891 rows and 1 columns. NOTE: 8834 row was inserted into S0.School1 /************************************************************************************************/ While run the Reg3 Macro Line NOTE: Table WORK.REG3 created, with 643391 rows and 1 columns. ERROR: CLI execute error: [Microsoft][ODBC SQL Server Driver]Invalid cursor state ERROR: ROLLBACK issued due to errors for data set S0.School1.DATA. NOTE: The SAS System stopped processing this step because of errors. What is this EROOR mean to it. I have no idea about an ERROR.. I google it for its description but I can't find it. Could you please explain, what cause an ERROR. Thanks in advance!
... View more