Thanks for all the insightful responses that help me solve my problem.
The original question is: how to call SAS from R
The solution is as below:
If my sas code, test.sas, is in directory c:\ncme06\sas codes, then the
following codes works
> system('"c:\\program files\\sas institute\\sas\\v8\\sas.exe"
"c:\\ncme06\\sas codes\\test"')
Things to notice:
1. need a single quote for the system function
2. need a double quote for BOTH the sas.exe and test files.
Thanks again.
David
-----Original Message-----
From: r-help-bounces@stat.math.ethz.ch
[mailto:r-help-bounces@stat.math.ethz.ch] On Behalf Of Prof Brian Ripley
Sent: Wednesday, August 24, 2005 12:33 PM
To: r-help@stat.math.ethz.ch
Subject: Re: [R] Call SAS from R
Date: Wed, 24 Aug 2005 18:05:44 +0100 (BST)
From: Prof Brian Ripley <ripley@stats.ox.ac.uk>
To: David Forrest <drf5n@maplepark.com>
Cc: "Shin, David" <david.shin@pearson.com>,
r-help@stat.math.ethz.ch,
'Don MacQueen' <macq@llnl.gov>,
bioconductor@stat.math.ethz.ch
Subject: Re: [R] Call SAS from R
On Wed, 24 Aug 2005, David Forrest wrote:
> On Wed, 24 Aug 2005, Shin, David wrote:
> ...
>>> system("c:\\program files\\sas institute\\v8\\sas.exe
test")
>> Warning message:
>> c:\program not found
>
> Escape the spaces too. It is trying to run the program c:\program or
> c:\progra~1\sas
Sorry that does not work. The Windows way is to quote it: e.g.
system('"c:/Program Files/Mozilla Firefox/firefox.exe"')
works (note the two sets of quotes), and this is explained with an example
on the help page ?system, so please do as the posting guide asks and read
the documentation ....
--
Brian D. Ripley, ripley@stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html
****************************************************************************
This email may contain confidential material.\ If you were n...{{dropped}}