Date: Fri, 8 Oct 1999 11:22:35 +0200
Reply-To: F a b r i z i o <Fabrizio1@USA.NET>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: F a b r i z i o <Fabrizio1@USA.NET>
Organization: KLM Royal Dutch Airlines
Subject: Re: "Secure" macro ?
James Carter wrote in message <85256803.00524392.00@sctmnot10.sctcorp.com>...
>Hello L-ers!
>
>I'm trying to come up with a "secure" macro, that is, one which
>cannot be viewed via the MPRINT (and/or MLOGIC) option. For
>macros that execute outside of a DATA step or PROC, it seems easy
>enough to just issue the "OPTIONS NOMPRINT" statement as the
>first line in the macro. But... for macros that resolve INSIDE a
>data step statement or PROC, the timing of producing an options
>statement doesn't work.
Hi James,
Though the following piece of code is not fool-proof, it is
a possible work-around for embedded OPTIONS statements.
First, the macro checks the settings of MPRINT MGEN SGEN etc.,
and if these are nor all masked, the macro does 2 things:
1) It turns off the corresponding options
2) It invokes itself as a nested macro, with these new options in effect.
Some notes: The parameter list (x=1, y=2, z=3) can be adapted
to whatever you need, but leave the /parmbuff intact. It is very
essential for the macro to be able to re-invoke itself.
You may still fool this macro through the use of old-style macros
(i.e. MACRO xxx %) that carry names like 'OPTIONS', 'MPRINT'
etc., and it takes much more effort to mask that too (it is possible,
but I am not allowed to publish that piece of proprietary software).
The piece of code that should be obscured can be inserted at
the comment box.
Here comes the code:
%macro secure (x=1, y=2, z=3) / parmbuff;
%local oldopt newopt;
%let oldopt= %sysfunc(getoption(macrogen ));
%let newopt= NOMACROGEN;
%let oldopt=&oldopt %sysfunc(getoption(symbolgen));
%let newopt=&newopt NOSYMBOLGEN;
%let oldopt=&oldopt %sysfunc(getoption(mlogic ));
%let newopt=&newopt NOMLOGIC;
%let oldopt=&oldopt %sysfunc(getoption(mprint ));
%let newopt=&newopt NOMPRINT;
%let oldopt=&oldopt %sysfunc(getoption(mtrace ));
%let newopt=&newopt NOMTRACE;
%if "&oldopt" ne "&newopt" %then %do;
options &newopt;
%secure &SYSPBUFF
options &oldopt;
%goto exit;
%end;
/*-----------------------------------------------------------------*/
/* */
/* Here comes the macro part which runs fully secured */
/* */
/*-----------------------------------------------------------------*/
%exit: %mend secure;
Hope this helps?
Grtz., Fabrizio