This code
data _null_;
set check;
%let path=/app/scripts_p2/jobs;
%let extn=sh;
x "&path/jobname.&extn";
cant't work because X is a global statement that is executed as soon as it is encountered in the program text, so it will ALWAYS resolve to
x "/app/scripts_p2/jobs/jobname.sh";
with "jobname" being a literal. Use call system() instead, which is a data step subroutine:
%let path=/app/scripts_p2/jobs;
%let extn=sh;
data _null_;
set check;
call system("&path./" !! trim(jobname !! ".&extn.");
run;
Also note that it makes your code easier to grok when the macro statements are placed before the data step, because that is the order in which they are executed anyway.
... View more