|
Bob,
When I use your code that uses %str or %quote, it works fine on my machine.
Of course, when I don't macro quote the clause, the error occurs, as
expected. I think you have a problem elsewhere.
-----Original Message-----
From: Bob Burnham [mailto:robert.a.burnham@DARTMOUTH.EDU]
Sent: Wednesday, November 13, 2002 11:34 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Q: Macro Vars with Equals, Parens, etc.
I'm wondering if anyone can pass on some sage advice about macro
quoting some strings that have special meaning to the macro
facility. Here is a quick example of something I'd like to do:
%macro myquery(dsn, clause);
proc sql;
select *
from &dsn
where &clause;
%mend;
So, I'd like to be able to pass in an SQL clause and see the
results printed to the screen -- pretty simple I thought.
So, I created some test data:
data test;
do x = 1 to 100;
y = x * 10;
z = y + 2;
output;
end;
run;
Then ran a quick test:
%myquery(test, x > 50);
Fine. No problems.
/* These don't work. . . */
However, as soon as I started trying things like:
%myquery(test, x = 5);
%myquery(test, %quote(x = 5));
%myquery(test, %str(x = 5));
%let clause= %str(x=5);
%myquery(test, &clause);
I started getting the error message that the "keyword parameter
x is not defined" (or something similar).
I've done a Google search and been flipping through my manuals,
but I'm not coming up with anything. Does anyone no the secret
to quoting something like this? In the best of all possible
worlds, it would also handle complex SQL expressions with lots
of parentheses, etc.
Thank you very much. I look forward to any responses.
Bob
--
Bob Burnham
bburnham@dartmouth.edu
http://www.dartmouth.edu/~bburnham
|