Date: Wed, 15 Mar 2006 17:15:56 -0500
Reply-To: "Wainwright, Andrea" <andrea.wainwright@CAPITALONE.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Wainwright, Andrea" <andrea.wainwright@CAPITALONE.COM>
Subject: I need a macro maven STAT!!!
Content-Type: text/plain; charset="us-ascii"
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.