Hi All,
I am new to post question on this list. I apologize if this question is too
easy or irrelevant.
I am doing a simulation study and I need to read a data file that can be
easily read by SAS.
So, what I try to do is to execute SAS in R and then read the output of SAS
to R.
I try the following code but it didn't work.
system("c:\\program files\\sas institute\\v8\\sas.exe test")
can anyone give me some help with this?
Thanks.
Davoid
****************************************************************************
This email may contain confidential material.
If you were not an intended recipient,
Please notify the sender and delete all copies.
We may monitor email to and from our network.
****************************************************************************
[[alternative HTML version deleted]]
perhaps it would be easier to read directly your datafile from R ? read.table(...) is your friend, and quite easy to use. type ?read.table under R. hih
Thanks for some kind responses from the list.
Maybe I should present my data here a little bit to explain why I want to
use SAS.
Below is part of my data set.
First, I need to skip the first 9 lines which I can use skip=9 to do this.
Second, I need to read to rows of data. the first row starts with
"M01" and
ends before "M02". The second row starts with "M02" to the
end.
Thanks for all the helps. I will appreciate if someone can answer my
original question or help me read this data in R.
G08MX.PLS YEAR X CALIBRATION
AUTOMATED FILE GENERATION
TEST 01 50 50 7 0 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1
GROUP 01
M01 20001 0.64822 0.03298 -1.25144 0.13812 0.16387
0.05688
0.00000 0.00000
0.00000 0.00000
M02 20002 1.02401 0.04124 -0.56511 0.04894 0.12076
0.02445
0.00000 0.00000
0.00000 0.00000
-----Original Message-----
From: r-help-bounces@stat.math.ethz.ch
[mailto:r-help-bounces@stat.math.ethz.ch] On Behalf Of vincent@7d4.com
Sent: Wednesday, August 24, 2005 10:58 AM
To: r-help@stat.math.ethz.ch
Subject: Re: [R] Call SAS from R
perhaps it would be easier to read directly
your datafile from R ?
read.table(...) is your friend, and quite easy to use.
type ?read.table under R.
hih
______________________________________________
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}}
How does it not work? Do you get error messages? Nothing at all? (it's difficult to help without more specific information, so this is a good time to suggest reading the posting guide: http://www.R-project.org/posting-guide.html) What happens if you try to run that exact command outside of R? Does it work? -Don At 10:22 AM -0500 8/24/05, Shin, David wrote:>Hi All, > >I am new to post question on this list. I apologize if this question is too >easy or irrelevant. > >I am doing a simulation study and I need to read a data file that can be >easily read by SAS. >So, what I try to do is to execute SAS in R and then read the output of SAS >to R. > >I try the following code but it didn't work. >system("c:\\program files\\sas institute\\v8\\sas.exe test") > >can anyone give me some help with this? >Thanks. > >Davoid > > >**************************************************************************** >This email may contain confidential material. >If you were not an intended recipient, >Please notify the sender and delete all copies. >We may monitor email to and from our network. >**************************************************************************** > > [[alternative HTML version deleted]] > >______________________________________________ >R-help at 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-- -------------------------------------- Don MacQueen Environmental Protection Department Lawrence Livermore National Laboratory Livermore, CA, USA
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 -----Original Message----- From: Don MacQueen [mailto:macq@llnl.gov] Sent: Wednesday, August 24, 2005 11:38 AM To: Shin, David; r-help@stat.math.ethz.ch; bioconductor@stat.math.ethz.ch Subject: Re: [R] Call SAS from R How does it not work? Do you get error messages? Nothing at all? (it's difficult to help without more specific information, so this is a good time to suggest reading the posting guide: http://www.R-project.org/posting-guide.html) What happens if you try to run that exact command outside of R? Does it work? -Don At 10:22 AM -0500 8/24/05, Shin, David wrote:>Hi All, > >I am new to post question on this list. I apologize if this question is too >easy or irrelevant. > >I am doing a simulation study and I need to read a data file that can be >easily read by SAS. >So, what I try to do is to execute SAS in R and then read the output of SAS >to R. > >I try the following code but it didn't work. >system("c:\\program files\\sas institute\\v8\\sas.exe test") > >can anyone give me some help with this? >Thanks. > >Davoid > > >****************************************************************************>This email may contain confidential material. >If you were not an intended recipient, >Please notify the sender and delete all copies. >We may monitor email to and from our network. >****************************************************************************> > [[alternative HTML version deleted]] > >______________________________________________ >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 -- -------------------------------------- Don MacQueen Environmental Protection Department Lawrence Livermore National Laboratory Livermore, CA, USA -------------------------------------- **************************************************************************** This email may contain confidential material.\ If you were n...{{dropped}}
On Wed, 24 Aug 2005, Shin, David wrote: ...> > system("c:\\program files\\sas institute\\v8\\sas.exe test") > Warning message: > c:\program not foundEscape the spaces too. It is trying to run the program c:\program or c:\progra~1\sas Dave -- Dr. David Forrest drf at vims.edu (804)684-7900w drf5n at maplepark.com (804)642-0662h http://maplepark.com/~drf5n/
Date: Wed, 24 Aug 2005 18:05:44 +0100 (BST)
From: Prof Brian Ripley <ripley at stats.ox.ac.uk>
To: David Forrest <drf5n at maplepark.com>
Cc: "Shin, David" <david.shin at pearson.com>, r-help at
stat.math.ethz.ch,
'Don MacQueen' <macq at llnl.gov>, bioconductor at
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 at 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
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