<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Error in batch file but not in SAS program in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Error-in-batch-file-but-not-in-SAS-program/m-p/869649#M343509</link>
    <description>&lt;P&gt;I'd suggest you turn on OPTIONS MPRINT and run the program as a batch job, then look at the the log from the PROC LIFETEST.&amp;nbsp; The log will show you whether _survdata3 is created.&amp;nbsp; But I don't see anywhere in the macro which would generate that error message.&amp;nbsp; Any chance it's coming from the %INCLUDE file?&amp;nbsp; Maybe turn on OPTIONS SOURCE2 as well, and then post the full log.&amp;nbsp; That should be enough for people to help you debug it.&lt;/P&gt;</description>
    <pubDate>Thu, 13 Apr 2023 19:10:29 GMT</pubDate>
    <dc:creator>Quentin</dc:creator>
    <dc:date>2023-04-13T19:10:29Z</dc:date>
    <item>
      <title>Error in batch file but not in SAS program</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-in-batch-file-but-not-in-SAS-program/m-p/869646#M343506</link>
      <description>&lt;P&gt;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.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;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(&amp;amp;sysprocessmode,2)); %put RunMode=&amp;amp;runmode;
******************************************************************************************************;
%global protdir;
%macro RunMode;
 	%if &amp;amp;runmode=BATCH %then %do; %let protdir=%sysfunc(prxchange(s/(\\SAS\\.+)//i,-1, %sysfunc(getoption(sysin)))); %end;
	%if &amp;amp;runmode=DMS %then %do; %let protdir=%sysfunc(prxchange(s/(\\SAS\\.+)//i, -1, %sysget(sas_execfilepath))); %end;
	%put protdir=&amp;amp;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= &amp;amp;dsnin. plots= survival;
	 where &amp;amp;pop. = 'Y' and paramn = &amp;amp;param.;
	 time aval*cnsr(1);		/*recovered: CNSR = 0*/
	%if &amp;amp;dur= N %then %do;
	 strata trta;
	%end;
	%if &amp;amp;dur= Y %then %do;
	 strata trtan dursymn;
	%end;
	 *format dursymn sym.;
	 ods output SurvivalPlot= _survdat&amp;amp;dsnout.;
	run;

	proc sql;
	%if &amp;amp;dur= N %then %do;
	 create table N as
	 	select trta, count(distinct usubjid) as n
			from &amp;amp;dsnin.
			where &amp;amp;pop. = 'Y' and paramn = &amp;amp;param.
			group by trta; 
	%end;
	%if &amp;amp;dur= Y %then %do;
	 create table N as
	 	select trta, dursymn, count(distinct usubjid) as n
			from &amp;amp;dsnin.
			where &amp;amp;pop. = 'Y' and paramn = &amp;amp;param.
			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.*/&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 13 Apr 2023 18:41:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-in-batch-file-but-not-in-SAS-program/m-p/869646#M343506</guid>
      <dc:creator>mariko5797</dc:creator>
      <dc:date>2023-04-13T18:41:26Z</dc:date>
    </item>
    <item>
      <title>Re: Error in batch file but not in SAS program</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-in-batch-file-but-not-in-SAS-program/m-p/869647#M343507</link>
      <description>&lt;P&gt;Since that dataset is the one generated by the ODS OUTPUT statement then I suspect that the actual issue is in the PROC LIFETEST step BEFORE then one that is complaining.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Reading the SAS log should help you see why the dataset was not created.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you do not have the MPRINT option turned on then that can also help make the log cleared by showing what code the macro is actually trying to run.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Apr 2023 18:59:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-in-batch-file-but-not-in-SAS-program/m-p/869647#M343507</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-04-13T18:59:57Z</dc:date>
    </item>
    <item>
      <title>Re: Error in batch file but not in SAS program</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-in-batch-file-but-not-in-SAS-program/m-p/869649#M343509</link>
      <description>&lt;P&gt;I'd suggest you turn on OPTIONS MPRINT and run the program as a batch job, then look at the the log from the PROC LIFETEST.&amp;nbsp; The log will show you whether _survdata3 is created.&amp;nbsp; But I don't see anywhere in the macro which would generate that error message.&amp;nbsp; Any chance it's coming from the %INCLUDE file?&amp;nbsp; Maybe turn on OPTIONS SOURCE2 as well, and then post the full log.&amp;nbsp; That should be enough for people to help you debug it.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Apr 2023 19:10:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-in-batch-file-but-not-in-SAS-program/m-p/869649#M343509</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2023-04-13T19:10:29Z</dc:date>
    </item>
    <item>
      <title>Re: Error in batch file but not in SAS program</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-in-batch-file-but-not-in-SAS-program/m-p/869652#M343511</link>
      <description>Checked the log. Seems like it wasn't printing the plot at all so I added ODS GRAPHICS ON, and seemed to fix the issue. Thank you!</description>
      <pubDate>Thu, 13 Apr 2023 19:33:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-in-batch-file-but-not-in-SAS-program/m-p/869652#M343511</guid>
      <dc:creator>mariko5797</dc:creator>
      <dc:date>2023-04-13T19:33:18Z</dc:date>
    </item>
  </channel>
</rss>

