In reading a previous post I understood it to say that a Macro Variable created with SYMPUT within a Macro procedure creates a Local Macro Variable. If that is the case, what happens if the Macro Variable has the same name as an already existing Global Macro.
For example: In open code I use Symput to create a Macro Variable called memname. I execute a Macro procedure in which Symput creates a Macro Variable called memname. What happens?
Here is some SAS code to exercise various SAS behavior - again I refer to the SAS DOC reference, which mentions that the RUN statement location is critical to how resolution with SYMPUT in a DATA step behaves. Sorry I can't find the link again - please check the archives.
call symput('a','I am global macro var a value');
%put global macro vars - diag1: ;
call symput('a','I am new macro var a value');
%put local macro vars - diag2: ;
%put local macro vars - diag3: ;
%put global macro vars - diag4: ;
It is possible to have both local and global macro variables with same name since the local macro variable is stored in the local symbol table and the global macro variable is stored in the global symbol table.
So, if you already have a value assigned to global macro variable and you create a local macro variable with same name then the macro variable within the macro definition resolves the value from local symbol table. And outside the macro it would resolve the value form global symbol table.
%put The value of DSN inside Printdsn is &dsn;
%put The value of DSN outside Printdsn is &dsn;