Date: Mon, 23 Dec 1996 09:49:56 -0500
Reply-To: Stephen McDaniel <mcdanies@PHARMARESEARCH.COM>
Sender: "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From: Stephen McDaniel <mcdanies@PHARMARESEARCH.COM>
Subject: Re: <None> (Bracketed/Conditional Macro Code)
Content-Type: text/plain; charset="us-ascii"
At 08:21 AM 12/23/96 -0500, John Iwaniszek wrote:
>I have a SAS problem that is probably not solvable in the way I would
>like to do it, but if any one can help me it would certainly make my day.
>
>I want to write two macros that I will use to bracket other macro calls.
>The function of the two bracket macros will be to determine whether the
>bracketed macros get executed. The bracketed macros can not be altered
>in any way.
John,
Here is one possible solution:
*** BEGINNING OF CODE;
*** Macro BRACKET is used throughout to selectively call macros;
*** N is the index number assigned to group relevant sections of code;
*** MACRO is the macro that may or may not be executed, do NOT include the;
*** percent sign in the macro name!;
%MACRO BRACKET(N,MACRO);
%IF %UPCASE(&&SKIP&N..) ne Y %THEN %&MACRO.;;
%MEND BRACKET;
*** Macro DOIT is just a macro to illustrate how BRACKET works;
%MACRO DOIT(TEXT1=Not Skipped!!!,TEXT2= );
%IF Y=Y %THEN %PUT &TEXT1. &TEXT2.;
%MEND DOIT;
*** For as many unique sections of macros you call, set up a skip macro;
*** variable. Note that these could also be set in DATA step statements;
*** using CALL SYMPUT;
%LET SKIP1=Y;
%LET SKIP2=N;
%LET SKIP3=N;
*** When you call your macros, specify what grouping this call is, and which;
*** macro to call (including parameters);
%BRACKET(1,DOIT); *** Does not execute;
%BRACKET(3,DOIT); *** Executes;
%BRACKET(2,DOIT(TEXT1= ,TEXT2=This does work!!!)); *** Executes;
*** END OF CODE;
*** LOG FROM RUNNING THE CODE;
1
2 *** BEGINNING OF CODE;
3
4 *** Macro BRACKET is used throughout to selectively call macros;
5 *** N is the index number assigned to group relevant sections of code;
6 *** MACRO is the macro that may or may not be executed, do NOT include the;
7 *** percent sign in the macro name!;
8 %MACRO BRACKET(N,MACRO);
9 %IF %UPCASE(&&SKIP&N..) ne Y %THEN %&MACRO.;;
10 %MEND BRACKET;
11
12 *** Macro DOIT is just a macro to illustrate how BRACKET works;
13 %MACRO DOIT(TEXT1=Not Skipped!!!,TEXT2= );
14 %IF Y=Y %THEN %PUT &TEXT1. &TEXT2.;
15 %MEND DOIT;
16
17 *** For as many unique sections of macros you call, set up a skip macro;
18 *** variable. Note that these could also be set in DATA step statements;
19 *** using CALL SYMPUT;
20 %LET SKIP1=Y;
21 %LET SKIP2=N;
22 %LET SKIP3=N;
23
24 *** When you call your macros, specify what grouping this call is, and
which;
25 *** macro to call (including parameters);
26 %BRACKET(1,DOIT); *** Does not execute;
27 %BRACKET(3,DOIT); *** Executes;
Not Skipped!!!
28 %BRACKET(2,DOIT(TEXT1= ,TEXT2=This does work!!!)); *** Executes;
This does work!!!
29
30 *** END OF CODE;
*** END OF LOG;
Best wishes,
Stephen McDaniel
Senior Statistical Programmer
PharmaResearch Corporation
Durham, NC 27707
(919) 403-9794
|