| Date: | Mon, 8 Sep 2003 04:40:56 -0400 |
| Reply-To: | "Thomasset Pierre (Office)" <pierre.thomasset@FORTISAG.BE> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | "Thomasset Pierre (Office)" <pierre.thomasset@FORTISAG.BE> |
| Subject: | Re: macro as macro parameter? |
|
Hello,
You can maybe adapt the following example, found in the SAS docs.
It uses the /parmbuff option in the %macro statement.
Regards.
*
Example 3: Using the %MACRO Statement with the PARMBUFF Option
The macro PRINTZ uses the PARMBUFF option to allow you to input a different
number of arguments each time you invoke it:
;
%macro printz /parmbuff;
%let num=1;
%let dsname=%scan(&syspbuff,&num);
%do %while(&dsname ne);
proc print data=&dsname;
run;
%let num=%eval(&num+1);
%let dsname=%scan(&syspbuff,&num);
%end;
%mend printz;
*
This invocation of PRINTZ contains four parameter values, PURPLE, RED,
BLUE, and TEAL although the macro definition does not contain any
individual parameters:
;
data purple; do i= 1 to 2; output; end; run;
data red; do i= 1 to 3; output; end; run;
data blue; do i= 1 to 4; output; end; run;
data teal; do i= 1 to 5; output; end; run;
%printz (purple, red, blue, teal);
*
As a result, SAS receives these statements:
;
PROC PRINT DATA=PURPLE;
RUN;
PROC PRINT DATA=RED;
RUN;
PROC PRINT DATA=BLUE;
RUN;
PROC PRINT DATA=TEAL;
RUN;
On Mon, 8 Sep 2003 12:13:54 +0800, Zibao Zhang <zibaozhang@HOTMAIL.COM>
wrote:
>Hi Leonora,
>
>Sorry, the subject should be "Macro variable as macro parameter?"!
>
>Maybe I haven't express my problem correctly, The problem is asked from my
friend, he want use &MacrVar to indict the parameters in %macro test, and
the &MacrVar. is generated from another macro. So now use %let to simply
the problem. the code seems be like this:
>
>%let MacrVar =N1, N2;
>
>%macro test(&MacrVar.);
>
> data _null_;
> Sum =(N1 + N2);
> Put sum;
> run;
>
>%mend test;
>
>%test(N1=10, N2=20);
>
>============
>Kind Regards,
>Zibao Zhang, MD
>
|