| Date: | Wed, 20 Oct 2010 11:29:45 -0500 |
| Reply-To: | Joe Matise <snoopy369@GMAIL.COM> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | Joe Matise <snoopy369@GMAIL.COM> |
| Subject: | Re: Macro quoting? |
| In-Reply-To: | <OF65905A49.D8EA702C-ON862577C2.00594A35-862577C2.0059717D@fd9ns01.okladot.state.ok.us> |
| Content-Type: | text/plain; charset=ISO-8859-1 |
|---|
Not a matter of quoting, but scope. A %let inside a macro is local to that
macro, so it's not in scope. You either need a %global statement beforehand
to bring it into global scope, or not to use a macro like that. You could
write the same macro as
%let specyr=2009;
%macro setwhere(specyr);
%if &SpecYr. ne %then "for &SpecYr. Specification Year.";
%else "for all Specification Years";
%mend setwhere;
%let SpecTitle = %setwhere(&specyr);
%put &spectitle;
for example, which moves the %let outside of the macro but doesn't create a
new global variable.
-Joe
On Wed, Oct 20, 2010 at 11:15 AM, Masoud Pajoh <mpajoh@odot.org> wrote:
> Why does the following not set SpecTilte?
>
> %let SpecYr=09;
>
> %macro SetWhere;
> %let where=;
> %let SpecTitle=for all Specification Years.;
> %if &SpecYr. ne %then %let SpecTitle= "for &SpecYr. Specification
> Year.";
> %mend SetWhere;
>
> %SetWhere;
>
> %put &SpecTitle.;
>
> Thanks,
>
> Masoud
>
|