Date: Wed, 22 Jul 2009 19:36:47 -0700
Reply-To: xlr82sas <xlr82sas@AOL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: xlr82sas <xlr82sas@AOL.COM>
Organization: http://groups.google.com
Subject: Re: Why is this macro variable GLOBAL/LOCAL?
Content-Type: text/plain; charset=ISO-8859-1
On Jul 22, 7:20 pm, Pobel <pobelgol...@gmail.com> wrote:
> Hi everyone,
>
> Plaese take a look at the following macro:
>
> %macro region;
> data a;
> value="aaa";
> call symput("DATAVAR", value);
> run;
>
> %if %symglobl(datavar) %then %put Macro variable DATAVAR is
> GlOBAL!;
> %else %put Macro variable DATAVAR is LOCAL!;
>
> proc sql noprint;
> select value into :SQLVAR
> from a;
> quit;
>
> %if %symglobl(sqlvar) %then %put Macro variable SQLVAR is
> GlOBAL!;
> %else %put Macro variable SQLVAR is LOCAL!;
> %mend;
>
> %region
>
> ---------------------------------------------------------
> The log:
> Macro variable DATAVAR is GlOBAL!
> Macro variable SQLVAR is LOCAL!
> ---------------------------------------------------------
>
> Would you please tell me why the macro variable DATAVAR is global
> while SQLVAR is local?
>
> Thank you very much!
>
> -Pobel
Take a look at
http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/tw3514-symput.htm
I think the issue is a result of no local symbol table for your macro
Untested hypothesis
If you put a dummy argument in your macro, then sqlvar will be local
ie
%macro region(dummy);
%mend region;
|