[R] Call SAS from R

Nordlund, Dan NordlDJ at dshs.wa.gov
Wed Aug 24 19:38:17 CEST 2005


David,

1. I assume you are working on a MS Windows OS given your system command.  
2. You need to determine what command will work to run your program from the
command line in Windows.  If your path is correct, then you can run SAS from
the command line like

      "c:\program files\sas institute\v8\sas.exe" test
      
Notice, the quotes do not include your SAS input file.  Also, you only use
single back-slashes on the command line.  If the above works for the Windows
command line, then go to 3.

3. The R command should then look like the following.

     System('"c:\\program files\\sas institute\\v8\\sas.exe" test') 

Notice that in R I have escaped the back-slashes, and have placed the whole
command in single quotes.  This ensures that the double quotes are passed on
to Windows.

Hope this helps,

Dan

Daniel J. Nordlund
Research and Data Analysis
Washington State Department of Social and Health Services
Olympia, WA  98504-5204

-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Shin, David
Sent: Wednesday, August 24, 2005 9:50 AM
To: 'Don MacQueen'; r-help at stat.math.ethz.ch; bioconductor at stat.math.ethz.ch
Subject: Re: [R] Call SAS from R


Thanks for the responses.
Here is the command I used and the error message I got.

> system("c:\\program files\\sas institute\\v8\\sas.exe test")
Warning message: 
c:\program not found

if I change "program files" to "progra~1" then the output is:
> system("c:\\progra~1\\sas institute\\v8\\sas.exe test")
Warning message: 
c:\progra~1\sas not found

I don't know how to change the folder name "sas institute" to let R reads
it. Can someone help me with this?

The strange thing is that if I type in the command 
"c:\\progra~1\\sas institute\\v8\\sas.exe test" in dos environment, it
didn't work, either.

I will appreciate very much if someone can help a bit. Thanks.

David




More information about the R-help mailing list