Date: Wed, 27 Oct 2004 14:49:25 -0400
Reply-To: "Richard A. DeVenezia" <radevenz@IX.NETCOM.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Richard A. DeVenezia" <radevenz@IX.NETCOM.COM>
Subject: Re: Attempt to %GLOBAL a name which exists in a local environment
Huang, Ya wrote:
> Hi there,
> Is there anyway I can make a parameter of a macro to be
> a global macro var ?
> 1 %macro a(parm=);
> 2 %global parm;
> 3 %mend;
> 5 %a(parm=HDL);
> ERROR: Attempt to %GLOBAL a name (PARM) which exists in a local
> Basically, I want to use &parm somewhere else, but it won't been
> seen unless I make it global macro var. Declare it as a global
> doesn't work as shown above.
You can't promote the scope of a local variable into the callers scope.
You will need to come up with a 'contract' between macro A and the place
that wants to use the value passed to A.
The contract in this case is simply agreeing upon a global macro variable
name that does not occur in the scope of A (or any other scope wishing to
use this value made globally available) and transferring the value into it.
%global g_parm; %* define contract;
%let g_parm=&parm; %* transfer;
%* use either &parm or &g_parm in A;
title "&g_parm was yada"; %* use contract;
Richard A. DeVenezia