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 (March 2006, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Thu, 16 Mar 2006 07:48:08 -0500
Reply-To:   Ed Heaton <EdHeaton@WESTAT.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Ed Heaton <EdHeaton@WESTAT.COM>
Subject:   Re: I need a macro maven STAT!!!
Comments:   To: "Wainwright, Andrea" <andrea.wainwright@capitalone.com>
Content-Type:   text/plain; charset="US-ASCII"

Andrea,

You %QUPCASE() preserves macro quoting (a misnomer, I believe) but you only want to preserve quotation marks. Quotation marks are never removed.

The problem is in the term MACRO QUOTING. What SAS calls macro quoting is really character masking. It has nothing to do with quotation marks, in general. Instead, it is used to keep the macro processor from misinterpreting some characters like commas, semicolons, left and right parentheses, and maybe ampersands and dollar signs.

Ed

Edward Heaton, SAS Senior Systems Analyst, Westat (An Employee-Owned Research Corporation), 1600 Research Boulevard, RW-4541, Rockville, MD 20850-3195 Voice: (301) 610-4818 Fax: (301) 294-3879 mailto:EdHeaton@Westat.com http://www.Westat.com

-----Original Message----- From: owner-sas-l@listserv.uga.edu [mailto:owner-sas-l@listserv.uga.edu] On Behalf Of Wainwright, Andrea Sent: Wednesday, March 15, 2006 5:31 PM To: SAS-L@listserv.uga.edu Subject: RE: I need a macro maven STAT!!!

OK, I got it to work, but I'd still love to hear why this works, and %qupcase didn't:

%macro var_list (exclude=); proc sql noprint ; select name into : Depvars separated by " " from dictionary.columns where libname = "WORK" and memname = "ABCDE" and upcase(name) not in ('A' 'B') ;

select name into : Depvars separated by " " from dictionary.columns where libname = "WORK" and memname = "ABCDE" and upcase(name) not in (%sysfunc(upcase(&exclude))) ;/*sysfunc works better*/ quit ; %mend;

-----Original Message----- From: Wainwright, Andrea Sent: Wednesday, March 15, 2006 5:16 PM To: 'SAS-L@LISTSERV.UGA.EDU' Subject: I need a macro maven STAT!!!

OK, I have a simple macro:

%macro var_list (exclude=); proc sql noprint ; select name into : Depvars separated by " " from dictionary.columns where libname = "WORK" and memname = "ABCDE" and upcase(name) not in (&exclude) ; quit ; %mend;

%var_list(exclude='A' 'B') %put model a = &DepVars ; %put model b = &DepVars ;

Works fine.

But, I can't be sure that people are going to upcase the exclude list.

So I thought I should do: %macro var_list (exclude=); proc sql noprint ; select name into : Depvars separated by " " from dictionary.columns where libname = "WORK" and memname = "ABCDE" and upcase(name) not in (%qupcase(&exclude)) ;/*added qupcase here to preserve single quotes*/ quit ; %mend;

But then my log shows: MPRINT(VAR_LIST): proc sql noprint ; SYMBOLGEN: Macro variable EXCLUDE resolves to 'A' 'B' NOTE: Line generated by the macro function "QUPCASE". 2 'A' 'B' - 22 - 202 MPRINT(VAR_LIST): select name into : Depvars separated by " " from dictionary.columns where libname = "WORK" and memname = "ABCDE" and upcase(name) not in ('A' 'B') ; ERROR 22-322: Syntax error, expecting one of the following: a quoted string, a numeric constant, a datetime constant, a missing value, (, -, SELECT.

ERROR 202-322: The option or parameter is not recognized and will be ignored.

MPRINT(VAR_LIST): quit ;

Of course the select statement it generates is perfect. I can cut and paste it into the editor window and run it just fine.

So what am I missing here?

(PC SAS v 9.1 if it helps)

The information contained in this e-mail is confidential and/or proprietary

to Capital One and/or its affiliates. The information transmitted herewith

is intended only for use by the individual or entity to which it is

addressed. If the reader of this message is not the intended recipient,

you are hereby notified that any review, retransmission, dissemination,

distribution, copying or other use of, or taking of any action in reliance

upon this information is strictly prohibited. If you have received this

communication in error, please contact the sender and delete the material

from your computer.


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