With the information provided in the WinBUGS Remote running page and Niels Peter Bådsgård’s additional instructions, I was able to run WINBUGS14 through SAS (V9.0) on Windows 2000 operating system.
The following information may help those who wish to do so.
Step 1:
Use the following SAS code to create a script file bugscript.txt; the winBUGS14 folder has to be in the root directory C:\, and bugscript must be in folder :
data _null_; filename scrip "C:\WinBUGS14\bugscript.txt"; file scrip; put ////// @@ #1 "display('log')" /* file BUGSCODE contains winBUGS code, file location needs to be specified in DOS format */ #2 "check('c:/docume~1/myfolder/bugscode.txt')" /* file BUGSDATA contains winBUGS data */ #3 "data('c:/docume~1/myfolder/BUGSdata.txt')" #4 "compile(1)" /* file BUGSINIT contains winBUGS initial values */ #5 "inits(1, 'c:/docume~1/myfolder/BUGSinit.txt')" / optional: use "gen.inits()" to generate initial values */ #6 "update(3000)" /* set variable names to be monitored, one command line for each variable*/ #7 "set(varname)" #8 "set(varname2)" #9 "update(2000)" /* call for stats to be output, one command for each variable */ #10 "stats(varnames)" /* coda file can be found in the same location as #11 "coda(varname,filename)" /* BUGS log will be saved as bugslog.txt */ #12 "save('c:/docume~1/myfolder/bugslog.txt')" #13 "quit()" ; run;
Step 2:
The following is the content in bugscript.txt generated by the SAS data step:
display('log') check('c:/docume~1/myfolder/bugscode.txt') data('c:/docume~1/myfolder/BUGSdata.txt') compile(1) inits(1, 'c:/docume~1/myfolder/BUGSinit.txt') update(3000) set(varname) set(varname2) update(2000) stats(varnames) save('c:/docume~1/myfolder/bugslog.txt') quit()
Step 3:
Run SAS X command. Again, the WinBUGS14 folder must be in the root directory.
data _null_; x "C:\WinBUGS14\WinBUGS14.exe /PAR bugscript.txt"; run; quit;
All Credits are due to Dr Niels Peter Bådsgård. I did not even do all the typing!
Jeng Mah, Guidant Corporation, St. Paul, Minnesota, USA