I have a macro that runs fine when I run within SAS. However, when I try to batch the file, I get the error that the dataset does not exist.
proc datasets library= work kill noprint; run;
/*dm "log; clear; output; clear; odsresults; clear;";*/
******************************************************************************************************;
options ls=max noquotelenmax pagesize=max ps=max missing=. compress= yes minoperator nofmterr;
ods listing close;
******************************************************************************************************;
%let runmode=%upcase(%scan(&sysprocessmode,2)); %put RunMode=&runmode;
******************************************************************************************************;
%global protdir;
%macro RunMode;
%if &runmode=BATCH %then %do; %let protdir=%sysfunc(prxchange(s/(\\SAS\\.+)//i,-1, %sysfunc(getoption(sysin)))); %end;
%if &runmode=DMS %then %do; %let protdir=%sysfunc(prxchange(s/(\\SAS\\.+)//i, -1, %sysget(sas_execfilepath))); %end;
%put protdir=&protdir;
%mend RunMode;
%RunMode;
%include 'G:\VID\NOROVIRUS\STAT\16-0092\24_Final Reports\SAS\source\16092_CSR_01_setup.sas';
%macro survdat( dsnout, /*output dataset*/
pop, /*analysis population, subgroup*/
param, /*best-case scenario = 1, worst-case scenario = 2*/
dur= N, /*by duration of symptoms = Y*/
dsnin= _1 /*input dataset*/
);
*ods listing close;
*ods graphics off;
proc lifetest data= &dsnin. plots= survival;
where &pop. = 'Y' and paramn = ¶m.;
time aval*cnsr(1); /*recovered: CNSR = 0*/
%if &dur= N %then %do;
strata trta;
%end;
%if &dur= Y %then %do;
strata trtan dursymn;
%end;
*format dursymn sym.;
ods output SurvivalPlot= _survdat&dsnout.;
run;
proc sql;
%if &dur= N %then %do;
create table N as
select trta, count(distinct usubjid) as n
from &dsnin.
where &pop. = 'Y' and paramn = ¶m.
group by trta;
%end;
%if &dur= Y %then %do;
create table N as
select trta, dursymn, count(distinct usubjid) as n
from &dsnin.
where &pop. = 'Y' and paramn = ¶m.
group by trta, dursymn;
%end;
quit;
data n;
set n;
if dursymn = 1 then label_ = catx(', ', trta, 'Acute');
if dursymn = 2 then label_ = catx(', ', trta, 'Chronic');
if missing(dursymn) then label_ = trta;
run;
%mend survdat;
%survdat(dsnout= 3, pop= mittfl, param= 1);
/*In batch file "ERROR: File WORK._SURVDAT3.DATA does not exist."*/
/*No error when ran directly in SAS.*/
... View more