LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (November 2002, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Wed, 13 Nov 2002 12:28:47 -0500
Reply-To:   "Nevseta, Floyd G" <Floyd.G.Nevseta@BANKOFAMERICA.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   "Nevseta, Floyd G" <Floyd.G.Nevseta@BANKOFAMERICA.COM>
Subject:   Re: Macro Vars with Equals, Parens, etc.
Comments:   To: Bob Burnham <robert.a.burnham@DARTMOUTH.EDU>
Content-type:   text/plain; charset=iso-8859-1

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


Back to: Top of message | Previous page | Main SAS-L page