[R] Sas to R
Nordlund, Dan (DSHS/RDA)
NordlDJ at dshs.wa.gov
Wed Sep 15 20:20:37 CEST 2010
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Sarah Jilani
> Sent: Wednesday, September 15, 2010 10:44 AM
> To: r-help at r-project.org
> Subject: [R] Sas to R
>
> Hi,
>
> I need to call an R program from Sas. I have tried using the following
> code
> in Sas using the x command but it just calls up dos and says
> 'D:\Program' is not recognized as an internal or external command,
> operable
> program or batch file.
> ]
> SAS CODE:
>
> options xwait xsync;
>
> %let Rsource=S:\EPI_Data\Communicable Diseases\DR1355 Historic
> Communicable
> Disease Analaysis\R graphics;
>
> options xwait xsync;
>
> x '"D:\Program Files\R\R-2.9.2\bin\Rgui.exe" --no-save --quiet
> <""&rsource.\Rtest.R""> ""&rsource.\Rtest.log""';
>
> What I need it to do is call R, run an R program and then go back to
> running
> sas. Any ideas on how to do that?
>
> Thanks!
>
> Sarah
>
Sarah,
I have found that making sure the command you wish to run will actually run at the command line is a big help. I suspect that the command, as you have specified it, will not run at the command line. Try copying everything inside the single quotes, open a command prompt, then paste the command and run it. I don't think it will do what you expect or want.
That being said, try something like
x '"D:\Program Files\R\R-2.9.2\bin\R.exe" --no-save --quiet < "&rsource.\Rtest.R" > "&rsource.\Rtest.log"';
You don't want to run Rgui.exe, use R.exe. In addition, you don't want to double your double-quotes, because they are inside single-quotes. Doubling them will cause problems. If this doesn't work, then the R-help related issue is figuring out how to run R from the command line with input and output redirection. The syntax I provide above should run just fine in Windows XP/Vista/7.
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
More information about the R-help
mailing list