Hello,
Is it legal to use same parameter in both outer and inner macro here?
%macro inner (ds = );
proc print data = &ds.;
run;
%mend;
%macro outer (ds =);
%inner(ds = &ds.);
%mend outer;
%outer (ds = sashelp.class)
You'll be fine. Do you understand the results that this variation would create?
%macro inner (ds = );
proc print data = &ds.;
run;
%let ds = temp;
%put Inner DS is &DS;
%mend;
%macro outer (ds =);
%inner(ds = &ds.);
%put outer DS is &DS;
%mend outer;
%outer (ds = sashelp.class)
It is legal.
It should be avoided unless absolutely necessary. It becomes difficult to tell what &DS refers to, since the values in the inner and outer macros do not have to match.
@Astounding @Reeza . Thanks. In my case the macro variable value is same in both outer and inner. I want to add the extra parameter in outer macro for further processing.
You'll be fine. Do you understand the results that this variation would create?
%macro inner (ds = );
proc print data = &ds.;
run;
%let ds = temp;
%put Inner DS is &DS;
%mend;
%macro outer (ds =);
%inner(ds = &ds.);
%put outer DS is &DS;
%mend outer;
%outer (ds = sashelp.class)
Yes, while the value in the outer macro remains unchanged.
You'll be fine with what you are planning.
Yes.
Not sure why some are saying it is not desirable. Use the same name if it makes the code easier to understand, or use different names if that makes more sense.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.