Date: Fri, 16 Jan 2009 09:19:02 -0600
Reply-To: "./ ADD NAME=Data _null_," <iebupdte@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "./ ADD NAME=Data _null_," <iebupdte@GMAIL.COM>
Subject: Re: question about sas macro variables
In-Reply-To: <d6a0d8f10901160605u7fbf3e85y211291834b8cc6f1@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1
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
|