@Tom wrote:
Making a LOCAL macro variable does not work. It just hides the value of the of the GLOBAL macro variable that the PROC creates.
Hi Again @Tom et al,
This has been bugging me off-an-on during the day, because I remember I did get my DOSUBL function-style macro working like I wanted at one point this morning before posting. Now at the end of the day I came back to it, and realized the DOSUBL problem I hit.
If you code:
%macro pwencode(password);
%local rc _pwencode;
%let rc=%sysfunc(dosubl(%nrstr(
proc pwencode in="&password" ;
run ;
)));
&_PWencode
%mend;
%let mypass=%pwencode(mypassword) ;
%put _user_ ;
By my understanding of the rules of DOSUBL magic, it 'should' work. I think PROC PWENCODE 'should' create the macro variable _PWENCODE in the side-session global symbol table, and then return the value of the macro variable to the main session local symbol table when DOSUBL completes. But that does not happen, instead PROC PWENCODE creates the macro variable _PWENCODE in the main session global symbol table. So this code does not work.
But, if you use a %LET statement in the DOSUBL block to create a global macro variable named _PWENCODE in the side session before calling PROC PWENCODE, then PROC PWENCODE will write to that macro variable. And this allows the function-style macro to work like I had intended. It avoids creating a global macro variable in the main session symbol table.
%macro pwencode(password);
%local rc _pwencode;
%let rc=%sysfunc(dosubl(%nrstr(
%let _pwencode= ; %*Create global macro variable in side session, PROC PWENCODE will assign it a value ;
proc pwencode in="&password" ;
run ;
)));
&_PWencode
%mend;
%let mypass1=%pwencode(aaa) ;
%let mypass2=%pwencode(bbb) ;
%put _user_ ;
... View more