|
v8.2
Works with %upcase.
108
109 options mprint;
110
111 %macro var_list (exclude=);
112 proc sql noprint ;
113 select name into : Depvars separated by " "
114 from dictionary.columns
115 where libname = "WORK"
116 and memname = "ABCDE"
117 and upcase(name) not in (%upcase(&exclude)) ;
118 quit ;
119 %mend;
120
121 %var_list(exclude='a' 'B')
MPRINT(VAR_LIST): proc sql noprint ;
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') ;
-----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: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.
_______________________________________________________________________
This e-mail may be privileged and/or confidential, and the sender does not waive any related rights and obligations.
Any distribution, use or copying of this e-mail or the information it contains by other than an intended recipient is unauthorized.
If you received this e-mail in error, please advise me (by return e-mail or otherwise) immediately.
Ce courrier électronique est confidentiel et protégé. L'expéditeur ne renonce pas aux droits et obligations qui s'y rapportent.
Toute diffusion, utilisation ou copie de ce message ou des renseignements qu'il contient par une personne autre que le (les) destinataire(s) désigné(s) est interdite.
Si vous recevez ce courrier électronique par erreur, veuillez m'en aviser immédiatement, par retour de courrier électronique ou par un autre moyen.
|