|
カテゴリ
|
ツール
|
説明
|
|---|---|---|
|
実行
|
CALL EXECUTEルーチン
|
渡された引数を置換し、置換した値を次のステップ境界で実行するか(値がSASステートメントの場合)、即座に実行します(値がマクロ言語要素の場合)。
|
|
置換
|
RESOLVE関数
|
DATAステップの実行中に、テキスト式の値を置換します。
|
|
削除
|
CALL SYMDELルーチン
|
引数で指定されたマクロ変数を削除します。
|
|
情報
|
SYMEXIST関数
|
マクロ変数が存在するかどうかを示す値を返します。
|
|
読み込みまたは書き込み
|
SYMGET関数
|
DATAステップの実行時にマクロ変数の値を返します。
|
|
情報
|
SYMGLOBL関数
|
マクロ変数のスコープがグローバルかどうかを示す値を返します。
|
|
情報
|
SYMLOCAL関数
|
マクロ変数のスコープがローカルかどうかを示す値を返します。
|
|
読み込みまたは書き込み
|
CALL SYMPUTルーチン
|
DATAステップで生成された値を、マクロ変数に割り当てます。
|
data prices; /* ID for price category and actual price */
input code amount;
datalines;
56 300
99 10000
24 225
;
%macro items;
%global special;
%let special=football;
%mend items;
data sales; /* incorrect usage */
set prices;
length saleitem $ 20;
call execute('%items');
saleitem="&special";
run;&specialという値が割り当てられます。
data prices; /* ID for price category and actual price */ input code amount; datalines; 56 300 99 10000 24 225 ; %let special=football; /* correct usage */ data sales; set prices; length saleitem $ 20; saleitem="&special"; run;
/* This version of the example shows the problem. */
data prices; /* ID for price category and actual price */
input code amount;
cards;
56 300
99 10000
24 225
;
data names; /* name of sales department and item sold */
input dept $ item $;
datalines;
BB Boat
SK Skates
;
%macro items(codevar=); /* create macro variable if needed */
%global special;
data _null_;
set names;
if &codevar=99 and dept='BB' then call symput('special', item);
run;
%mend items;
data sales; /* attempt to reference macro variable fails */
set prices;
length saleitem $ 20;
if amount > 500 then
call execute('%items(codevar=' || code || ')' );
saleitem="&special";
run;/* This version solves the problem. */
data prices; /* ID for price category and actual price */
input code amount;
datalines;
56 300
99 10000
24 225
;
data names; /* name of sales department and item sold */
input dept $ item $;
cards;
BB Boat
SK Ski
;
%macro items(codevar=); /* create macro variable if needed */
%global special;
data _null_;
set names;
if &codevar=99 and dept='BB' then
call symput('special', item);
run;
%mend items;
data _null_; /* call the macro in this step */
set prices;
if amount > 500 then
call execute('%items(codevar=' || code || ')' );
run;
data sales; /* use the value created by the macro in this step */
set prices;
length saleitem $ 20;
saleitem="&special";
run;