> -----Original Message----- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- > project.org] On Behalf Of ziad.elmou...@tnsglobal.com > Sent: Wednesday, November 24, 2010 3:27 AM > To: r-help@r-project.org > Subject: [R] Running R from SAS > > Hello All, > > I am interested in running an R program with several random seeds. One > approach is to launch the program from SAS. The recommended approach > is to use the X command as shown below: > OPTIONS XWAIT XSYNC; > > X "r.exe --no-save --quiet <""c:\temp\r\program.r"" > >""c:\temp\r\program.log"""; > > However, this does not seem to work for me. Does anyone know how to > launch an R program from SAS? Thank you in advance. > > Ziad Elmously > > ziad.elmou...@tnsglobal.com > >
You haven't given enough information for anyone to offer you anything more than educated guesses. What do you mean " this does not seem to work for me"? What error messages are you getting. If you want to run R from SAS (or any other program) you need to figure out what command will work from the command line. I assume your unstated OS is some version of MS Windows. What version of R? Is R.exe in your path? If not you need either need to add the path to SAS to your PATH environment variable, or you need to give the full path in the x command. Try entering your command at the windows command prompt (you have no spaces in your filenames/paths so the quotes aren't necessary) R --no-save --quiet <c:\temp\r\program.r c:\temp\r\program.log If the command doesn't work then let us know what the errors are. This is the syntax I sometimes use on my machine: x 'c:\R\R-2.12.0\bin\x64\R.exe --vanilla <c:\SAS_examples\run_R_from_SAS_test.R >c:\SAS_examples\run_R_from_SAS_test.out'; Since I have R in my PATH, I could have just used x 'R --vanilla <c:\SAS_examples\run_R_from_SAS_test.R >c:\SAS_examples\run_R_from_SAS_test.out'; I could have also used Rcmd BATCH like this; x 'Rcmd BATCH --vanilla c:\SAS_examples\run_R_from_SAS_test.R'; and the output would be placed in c:\SAS_examples\run_R_from_SAS_test.Rout automatically. Hope this is helpful, Dan Daniel J. Nordlund Washington State Department of Social and Health Services Planning, Performance, and Accountability Research and Data Analysis Division Olympia, WA 98504-5204 ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.