You have two problems. The first is that the statements in CALL EXECUTE() are not executed before after the datastep. But I assume that you have already changed your code to DOSUBL(), as others have suggested that. The other problem is that the whole datastep is compiled before it is executed, meaning that the macro variable is parsed before the datastep is executed. To get the value assigned by the query, you should use SYMGET to get it: data _null_;
rc=dosubl('proc sql;select distinct status into :dps from depst;quit;');
if symget('DPS') = 'P' then do; But this is probably not the easiest way to get the values. It is probably easier to create the list of jobs to be run in a new table: proc sql;
create table jobs_to_run as select
check.jobname,
check.val,
master.dependentjobname,
check2.runstatus
from
check join master
on check.jobname=master.jobname
join check check2
on master.dependentjobname=check2.jobname
;
quit;
You can now just set the table and submit the batchjob if runstatus='P' and val='1'. Of course, you may have to check if you have already submitted the job once: proc sort data=jobs_to_run;
by jobname;
run;
data _null_;
job_already_run=0;
do until(last.jobname);
set jobs_to_run; by jobname;
if job_already_run then
continue;
if val='1' and runstatus='P' then do;
/* submit batch job */
job_already_run=1;
end;
run;
... View more