已知两数据集a和b,要求在b中找出满足a条件的数据。当然有很多种方法做,下面我用的是宏变量传递做sql查询。出现错误显示:The following columns were not found in the contributing tables: A.(and B)。我想错误可能在于name是字符变量,而macro main中传递过去的并不是字符变量,所以显示找不到匹配数据。
Q1:如何修改macro main能满足要求?
Q2:是否可以用hash object做表连接,如何写code?
data a;
input name $ ;
cards;
A
B
;
run;
data b;
input name $ tt;
cards;
A 1
A 2
A 3
B 4
B 5
C 5
C 7
C 8
;
run;
%macro main;
data _null_;
set a end=last;
call symput(('name'||compress(_n_)),name);
if last then call symput('num',_n_);
run;
%do i=1 %to #
proc sql;
select *
from b
where name=&&name&i
;
%end;
quit;
%mend main;
%main;