Submits a sas program in batch using systask

%macro batch_run_generic(tab=,timeout=120);

%let progfile=&tab..sas;
%let logfile=&tab..log;
%let lstfile=&tab..lst;

%if %file_exist(file=&progfile. ) = 0 %then %do;
options mprint;
data _null_;
length command $2000;

command= strip(cat ('systask command   ',"'",'"C:\Program Files\SASHome\x86\SASFoundation\9.3\sas.exe"'  ,     
   ' -sysin ',  '"',"&progfile.",'"',  
   ' -log ',  '"',  "&logfile.",'"', 
   ' -print ','"',  "&lstfile.",'"',
   ' -noterminal -rsasuser -nosplash -nologo ',"'", ' status=runstat taskname=temp;  ')) ;
call symput('command',command);
run;
&command;waitfor temp timeout=&timeout;
proc sql;
insert into joblog.jobs
set  study="xx",
     path="xx",
     job="&tab",
     status=put(&runstat,jstat.),
     status_cd=&runstat,
     runtime=put(datetime(),datetime20.);
quit;
%if %file_exist(file=&logfile. ) = 0 %then %do;
%logscan(logfile=&logfile.);
%end;

%if &runstat = 0 %then %put &tab ran ok;
%else %if &runstat = 2 %then %put job failed with errors check &logfile.;
%else %if &runstat = 1 %then %put job completed with warning check &logfile.;
%else %put job failed  check &logfile.;
%end;
%else %put program does not exist check name;
%mend;