下面的代码 1 根据用户提示输入在 Proc SQL 中创建 where 子句('Str' 表示商店编号)我想使用宏(参见下面的示例代码 2)来替换宏变量。请问我怎样才能让它工作?谢谢!
代码 1:
%global STR_COUNT STR;
%let STR_WHERE_CLAUSE=;
data _null_;
if missing(symget('str'))=0 then
do;
length STR_LIST $1000;
STR1=symget('STR');
STR2=put(input(STR1,best4.),z4.);
STR_LIST=quote(STR2);
put STR_LIST;
end;
if missing(STR_LIST)=0 then
call symputx('STR_WHERE_CLAUSE',cats(' and T1.STR_SITE_NUM in (',STR_LIST,')'));
run;
%PUT &STR_Where_Clause;
代码 2:
%macro condition3(table=);
and &table..store in ('1234')
%mend condition3;
然后我可以像使用宏变量一样在 SQL 中使用宏。
select xxx from t1, t2 where condition1
and condition2
%condition3(table=t6)