Invoking SAS 9.2 to edit a program from the comman

2019-07-20 12:58发布

I've been Googling for an hour and can't find what should be the easiest thing.

I want to invoke SAS from the command line to edit a SAS program.

If I do this:

C:\Program Files\SAS\SASFoundation\9.2(32-bit)\sas.exe mysasprogram.sas

it simply executes mysasprogram.sas.

Help!

Thanks!

标签: sas
3条回答
我想做一个坏孩纸
2楼-- · 2019-07-20 13:26

Create files:

E:\sasedit.bat

set _pgm=%1
start "start" "C:\Program Files\SASHome\SASFoundation\9.3\sas.exe" -autoexec "E:\autoexec.sas"

E:\autoexec.sas

%let _pgm=%sysget(_pgm);
dm "whost;include '&_pgm';";
  • mysasprogram.sas with anycontent in a path that doesn't require quotes (in DOS).

Run command:

E:\sasedit.bat E:\pathtomyfile\mysasprogram.sas

The syntax of autoexec code: DM is display manager, WHOST command is calling SAS Enhanced Editor.

To use this with path requiring quotes you'd have to provide path in quotes and add some quoting treatment to autoexec code.

Another way to run some initial commands is via INITSTMT SAS command line option, but there will we have a problem with lots of quoting.

查看更多
再贱就再见
3楼-- · 2019-07-20 13:35

I had some trouble getting vasja's answer to work -- the call to %sysget was unable to retrieve the variable.

I ended up using a single file (launchsas.cmd):

set fn=%1
set fn=%filename:"=%
set command="%%let filename='%fn%'; dm 'whost;include &filename.;';"
start "start" C:\path\to\sas.exe -initstmt %command%

Note that the creation of the "filename" variable is to avoid problems with embedded quotation marks.

查看更多
做个烂人
4楼-- · 2019-07-20 13:40

After digging through my registry and some more Googling, I got to this solution, that seems to work. However, I haven't played enough to know the differences between SAS.EXE and SASOACT.EXE.

SASOACT.EXE action=Open datatype=SASFile filename="mysasprogram.sas"
查看更多
登录 后发表回答