Reputation: 4534
I am using SAS 9.4 for Windows 7. When I run anything in batch mode, such as SASUnit, I get a dialog stating
This window is unavailable in line-mode.
My AUTOEXEC.sas
contains these two lines which open the work library and maximize the IDE window:
dm 'dmsexp; expand libraries; expand work;';
dm 'awsmaximize on';
The error happens because there is no windowing environment when run in batch. The dm
statements don't apply.
It seems like the obvious solution, i.e. test whether SAS is running in batch mode or not, doesn't apply on Windows. The SYSENV variable "reports whether SAS is running interactively." Yet on Windows, SYSENV
always contains the value FORE
, the value which indicates "when you run SAS interactively through a windowing environment".
Is there a workaround for this other than opening my AUTOEXE.sas
and commenting out those two lines every time I need to run something in batch? Maybe there is command-line switch, such as --no-init-file
for Emacs, which skips running AUTOEXEC.sas
?
Upvotes: 1
Views: 650
Reputation: 1
The dm
statement is doing it (inside the code). It got solved when I commented that dm
statement.
Upvotes: 0
Reputation: 51611
If you want to know whether or not you can use Display Manager commands just check if Display Manager is running or not.
%if DMS=%sysfunc(getoption(dms)) %then %do;
dm 'dmsexp; expand libraries; expand work;';
dm 'awsmaximize on';
%end;
Note starting with SAS 9.4M5 you could include this exact code in your autoexec.sas file without having to first wrap it into a macro.
If you are using an old version of SAS then you could use a data step with call execute()
instead.
data _null_;
if 'DMS'=getoption('dms') then call execute(
"dm 'dmsexp; expand libraries; expand work';dm 'awsmaximize on';"
);
run;
Upvotes: 4
Reputation: 7769
Just use the -noterminal
option when invoking SAS as a batch job.
Also :
Note: The -NOSTATUSWIN option enables you to run SAS in batch mode so that no windows are displayed. You can add options such as -NOTERMINAL, -NOSPLASH, -NOSTATUSWIN, and -NOICON to prevent the windows from being displayed.
Upvotes: 3