|
Amazing! I agree, no use of this comes straight to mind, other than
being a nice addition to Art Carpenters "Maximise Your
Indespensability" paper, but it is nontheless very cool.
I will try to think of a practical use for this :)
Thanks
2009/1/16 ./ ADD NAME=Data _null_, <iebupdte@gmail.com>:
> On 1/16/09, karma <dorjetarap@googlemail.com> wrote:
>> I think this raises another interesting question, can SAS macro create
>> macro code that is executable at a later time? As far as I know, Lisp
>> allows macro code to create macro code ad infinitum. I don't think SAS
>> does allow this, but I would be happy to be proven wrong on this. An
>> example:
>>
>> %let c = %superq(%put 1;);
>> %unquote(c);
>
> This doesn't work because SUPERQ only works on macro variables and the
> unquote is missing & for &C. But it can be made to work see lines 1
> and 2 below. The rest is a macro that writes a macro. I can't think
> of a use for this today but I think I actually coded something similar
> many years ago when I was "macro happy".
>
>
>
> 1 %let c = %nrstr(%%put NOTE: &systime;);
> 2 %unquote(&c);
> NOTE: 09:08
> 3
> 4
> 5 %macro writes1(name=hello);
> 6 %let macro = %nrstr(%%)macro &name(called=&sysmacroname)
> %nrstr(; %%put NOTE: MY name is &sysmacroname,
> 6 ! called by &called; %%mend;);
> 7 %put _local_;
> 8 %unquote(¯o)
> 9 %unquote(%&name)
> 10 %mend writes1;
> 11
> 12
> 13 %writes1;
> WRITES1 MACRO macro hello(called=WRITES1) put NOTE: MY name is
> sysmacroname called by called mend
> WRITES1 NAME hello
> NOTE: MY name is HELLO, called by WRITES1
>
|