A slight modification to my solution: you can also put the RUN statement inside the macro, as log as you do not put the final semicolon.
%macro mc_get_program_name;
data _null_;
call symputx('v_path_prog',catx('/',symget('SYSINCLUDEFILEDIR'),symget('SYSINCLUDEFILENAME')));
run
%mend;
Then, in your %INCLUDE program, just use the macro call with a semicolon:
%mc_get_program_name;
and things should work as you want, the datastep does not get executed before SAS encounters the semicolon (which is outside the macro).
... View more