以下のコード 1 は、ユーザー プロンプト入力 (ストア番号の場合は「Str」) に基づいて Proc SQL に where 句を作成します。マクロ (以下のサンプル コード 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)