Date: Fri, 15 Jan 2010 17:52:30 +0100
Reply-To: Andre Wielki <wielki@INED.FR>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Andre Wielki <wielki@INED.FR>
Subject: Re: Why I cann't use %local like this?
In-Reply-To: <b7a7fa631001150828p7d3abb53y8338aeabd3646a3d@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Look perhaps at the difference between
this where MV a is not created
%macro t1;
a
%mend;
%macro t2;
%local b;
%local %t1;
%local c;
/*%let a= empty; */
%put _local_;
&a
&empty ;
%put _user_;
%t1
%mend;
options mprint mlogic symbolgen;
%t2;
and this one where there is a text content inside a
%macro t1;
a
%mend;
%macro t2;
%local b;
%local %t1;
%local c;
%let a= empty;
%put _local_;
&a
&empty ;
%put _user_;
%mend;
options mprint mlogic symbolgen;
%t2;
Andre
now we must reread SAS documentation!!!
Joe Matise a écrit :
> Hmm, good point. And & variables certainly work:
> %let t1=a;
> %macro t2;
> %local &t1 c;
> %local b;
>
> %put _local_;
> %mend;
> options source2 mprint mlogic symbolgen;
> %t2;
>
> Must be something with 'local' and a macro call confusing what it's local
> to. When you use %global, it works as expected.
>
> -Joe
>
>
> On Fri, Jan 15, 2010 at 10:23 AM, Yu Zhang <zhangyu05@gmail.com> wrote:
>
>
>> But if you declare a local macro var like
>> %local B;
>>
>> in macro 2 and no value was assigned,
>>
>> Mvar B is in the local table. can someone explain why the form of "%local
>> %t1" can not get the mvar a to the table?
>>
>>
>> %macro t1;
>> a
>> %mend;
>> %macro t2;
>> %local %t1;
>> %local b;
>>
>> %put _local_;
>> %mend;
>> options mprint mlogic symbolgen;
>> %t2;
>>
>> Thanks!
>>
>> Yu
>>
>>
>> On Fri, Jan 15, 2010 at 9:36 AM, Joe Matise <snoopy369@gmail.com> wrote:
>>
>>
>>> I believe it's because you haven't assigned it a value yet.
>>>
>>> -Joe
>>>
>>> On Fri, Jan 15, 2010 at 12:19 AM, jiyuan123 <jiyuan123@gmail.com> wrote:
>>>
>>>
>>>> Dear SAS-Lers,
>>>>
>>>> I want use a macro to generate some macro local variables. like this,
>>>>
>>>>
>>>> %macro t1;
>>>> a
>>>> %mend;
>>>> %macro t2;
>>>> %local %t1;
>>>> %put _local_;
>>>> %mend;
>>>> options mprint mlogic symbolgen;
>>>> %t2;
>>>>
>>>> why I cann't get macro local variable "A" in %t2?
>>>>
>>>> thanks a lot.
>>>> jiyuan123
>>>>
>>>>
>>
>
>
--
André WIELKI
INED (Institut National d'Etudes Démographiques)
Service Informatique
133 Boulevard Davout 75980 Paris Cedex 20
mél : wielki@ined.fr tél : 33 (0) 1 56 06 21 54
|