I have been trying to create some useful autocall macros for use in future programs and I have run into a bit of an implementation problem.
I am trying to create a macro that will take the first parameter to determine the type of variables to create and the second parameter to declare what values to assign the variables. Here is what I have so far with a month example
%macro ifvar(parm1, parm2);
%if %upcase(&parm1) = MON %then %do;
%if %upcase(&parm2)=JAN %then %do;
data _null_;
call symput('month', 'January');
call symput('mm','01');
run;
%end;
%if %upcase(&parm2)=FEB %then %do;
data _null_;
call symput('mm','02');
call symput('month','February');
run;
%end;
..........
%end;
%if %upcase(&parm1) = MM %then %do;
%if %upcase(&parm2)=01 %then %do;
data _null_;
call symput('month','January');
call symput('mon','jan');
run;
%end;
..............
%end;
..................
%mend ifvar;
The problem is that %ifvar creates parm1 and parm2 in its local table so the new variables all get created there and when I try to pass it to the outer table in a dummy macro it comes out empty. I am able to get them to pass to an outer table if I take out the parameters and simply declare them with a %local and %let statement in the outer macro but this seems to defeat the purpose of parameters.
Any suggestions for how to deal with this or advice on what I am doing wrong? I am trying to avoid having to declare a global variable list each time this macro is run to keep things tight but I am thinking that may be the only answer.
-Thanks