Is it possible to return a value from a SAS macro, and continue the current SAS line after returning the value?
e.g. Desired output to SAS (without quotes):
"set test.hello_2018_2020_2028;"
I've tried the following:
%MACRO returnFunc(passVar);
%local testReturn;
%let testReturn = %eval(&passVar +1);
&testReturn
%return;
%MEND returnFunc;
%MACRO test;
%local var1;
%local varPassed;
%local anotherVar;
%let var1 = 2018;
%let varPassed = 2019;
%let anotherVar = 2028;
set test.hello_&var1._%returnFunc(&varPassed)_&anotherVar;
%MEND test;
However I get errors like the following:
File test.hello_2018_2020.DATA does not exist
File WORK._2028 Does not exist
So the macro returns the value fine, however it starts trying to make another set statement instead of adding _&anotherVar to the set statement
&
in front oftestReturn
in the first macro. Also, try removing the period after%returnFunc(&varPassed).
. – J_Lard