h***i 发帖数: 115 | 1 书上的例子
1. p403
%macro counts (cols=_all_,rows=,dsn=all);
proc freq data=&dsn;
tables
%if &rows ne %then &rows * ; (为什么这里需要 ; ) ???
&cols;
run;
%mend counts;
%counts(dsn=all,cols=paid,rows=course_number)
2. P394 point 7
%macro outer;
%local variX;
%let variX=one;
%inner
%mend outer;
%macro inner;
%local variY;
%let variY=&variX;
%mend inner;
%let variX=zero;
%outer
书上说when executes macro Inner, the local Macro variable variY is assigned
the other local macro variabl | s******r 发帖数: 1524 | 2 1. ; is for %if
without ;
it will run as
proc freq data=&dsn;
run;
SAS will take &cols as part of %if
【在 h***i 的大作中提到】 : 书上的例子 : 1. p403 : %macro counts (cols=_all_,rows=,dsn=all); : proc freq data=&dsn; : tables : %if &rows ne %then &rows * ; (为什么这里需要 ; ) ??? : &cols; : run; : %mend counts; : %counts(dsn=all,cols=paid,rows=course_number)
| s******r 发帖数: 1524 | 3 2. if local and global macro variables share same name,
within macro, SAS will take local macro variable
Imagine if SAS take global macro variable within macro, it will be
impossible for you to pack your macro, it always impacted by global macro
variable outside.
hopefully it helps.
【在 h***i 的大作中提到】 : 书上的例子 : 1. p403 : %macro counts (cols=_all_,rows=,dsn=all); : proc freq data=&dsn; : tables : %if &rows ne %then &rows * ; (为什么这里需要 ; ) ??? : &cols; : run; : %mend counts; : %counts(dsn=all,cols=paid,rows=course_number)
| h***i 发帖数: 115 | |
|