Date: Wed, 6 Aug 2003 10:21:33 -0400
Reply-To: Sigurd Hermansen <HERMANS1@WESTAT.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Sigurd Hermansen <HERMANS1@WESTAT.COM>
Subject: Re: Question on Macros...
Content-Type: text/plain
You may want to add OPTIONS MPRINT; to your program so you can see how the
macrovariables resolve. In a crude test the %str( ) macrofunction takes care
of the small problem in the parsing of the macro parameter values:
%CREATE_TBL(MNXCE); %ADD_ROW_COND(MNXCE,TOT_OPEN_ACCTS,COUNT(*),
NUMBER OF OPEN/ACTIVE ACCOUNTS,
%str(ACCT_STATUS='C'));
Sig
-----Original Message-----
From: Manik [mailto:mvatyam@HOUSEHOLD.COM]
Sent: Wednesday, August 06, 2003 10:03 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Question on Macros...
Following is the progran, i am working on. I wrote a SQL expression in macro
and calling that macro as follows...
I am passing WHERE condition "ACCT_STATUS='C'" to SELECT statement in macro
ADD_ROW_COND using variable VAR_WHERE.. i got the following error..
-----------
ERROR: The keyword parameter ACCT_STATUS was not defined with the macro.
I tried pass the condition as a string
%LET VAR1 = %STR(ACCT_STATUS = %'C%'); and i passed &VAR to VAR_WHERE in
macro.. i gotthe following error
67 ACCT_STATUS = 'C'
_
_
_
22
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted
str ing, a numeric constant, a datetime constant, a missing value, (, *,
+, -, ALL, ANY, BTRIM, CALCULATED, CASE, INPUT, LOWER, PUT, SELECT,
SOME, SUBSTRING,
TRANSLATE, UPPER, USER.
---------------
Could you please have allok and let me know, where i am doing wrong.....
Thanks in advance......
**********
DATA ACTIVE1;
INFILE HFCBEN;
INPUT
@169 ACCT_STATUS $CHAR1.
RUN;
%MACRO CREATE_TBL(TABLE_NAME);
PROC SQL ;
CREATE TABLE &TABLE_NAME
( COL_NAME CHAR(20),
COL_DESC CHAR(50),
COL_VALUE NUM );
QUIT;
%MEND CREATE_TBL;
%MACRO ADD_ROW_COND(TBL_NAME,VAR_NAME,VAR_SELECT,
VAR_DESC,
VAR_WHERE);
%PUT "VAR SELECT : " &VAR_SELECT;
%PUT "VAR WHERE : " &VAR_WHERE;
PROC SQL ;
INSERT INTO &TBL_NAME
SET COL_NAME = "&VAR_NAME",
COL_DESC = "&VAR_DESC",
COL_VALUE =
( SELECT &VAR_SELECT
FROM ACTIVE1
WHERE &VAR_WHERE);
QUIT;
%MEND ADD_RO%CREATE_TBL(MNXCE);
%CREATE_TBL(MNXCE); %ADD_ROW_COND(MNXCE,TOT_OPEN_ACCTS,COUNT(*),
NUMBER OF OPEN/ACTIVE ACCOUNTS,
ACCT_STATUS='C');
***************
|