Hi,
Please show the code you have tried. This will make it easier to explain why it's not working.
It's a good idea to always use the %LOCAL or %GLOBAL statement to explicitly declare the scope of macro variables (there are rare exceptions to this rule).
Yes you can use the %GLOBAL statement in a macro to create a global macro variable, for example:
%macro try() ;
%global x ;
%let x=1 ;
%mend try ;
%try()
%put &=x ;
No, if you have a local macro variable, you cannot use the %GLOBAL statement to redefine it as global. The below log shows the error that will be generated if you try:
615 %macro try() ;
616 %local x ;
617 %let x=1 ;
618 %global x ;
619 %let x=1 ;
620 %mend try ;
NOTE: The macro TRY completed compilation without errors.
15 instructions 236 bytes.
621
622 %try()
ERROR: Attempt to %GLOBAL a name (X) which exists in a local environment.
HTH,
-Q.