Date: Tue, 27 Oct 1998 09:01:12 -0500
Reply-To: "Dorfman, Paul" <pdorfma@UCS.ATT.COM>
Sender: "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From: "Dorfman, Paul" <pdorfma@UCS.ATT.COM>
Subject: Re: Problem evaluating a macro variable
Content-Type: text/plain
Dave Boylan, in part, wrote:
>I'm having a bit of trouble with the following macro:
> %macro DoFreq(stat=);
> Proc freq data = test (where=(state eq &stat ));
> table baserate*custchrg*ratecd /list out= work.&stat;
> run;
> %mend DoFreq;
> %DoFreq(stat='CO');
>
>Seems the problem lies in the "out= work.&stat" part. It is evaluating to
>"Work.'CO'"
Dave,
When you call the macro, you assign 'CO' - together with quotes - to the
macrovariable stat. And this is exactly to what &stat resolves. In other
words, the phrase work.&stat becomes work.'stat'. Therefore, PROC FREQ
receives a syntactically incorrect construct and does not compile. If you
turn the option MPRINT on you will see it quite clearly. However, in the
text generated by the macro, you want to obtain work.CO. Accordingly, assign
this value, without any quotes whatsoever to the parameter stat:
%DoFreq (stat=CO)
and you should be fine provided that the dataset (or view) TEST exists and
contains the variables specified on the TABLE statement. As the correct
syntax is actually TABLES (as opposed to PROC TABULATE), you may receive a
friendly warning that the word has been misspelled, but SAS is smart enough
to replace it with the right one.
Good luck!
Kind regards, Paul.
++++++++++++++++++++++++++++++++++++
Paul M. Dorfman
CitiCorp UCS Decision Support
Jacksonville, FL
++++++++++++++++++++++++++++++++++++
|