[R] Calling SAS from R

Uwe Ligges ligges at statistik.tu-dortmund.de
Mon Mar 1 13:31:57 CET 2010



On 01.03.2010 08:42, Yen Lee wrote:
> Thank you for your reply.
>
>
>
> Because my R program is Chinese version,
>
> I would try my best to translate and specify my question more precisely.
>
>
>
> When I type
>
> system('"c:\\Program Files\\SAS\\SAS
> 9.1\\sas.exe","c:\\entropy\\output7\\scale\\syntax.sas"')
>
> The warning message is as follow,
>
> In system("\"c:\\Program Files\\SAS\\SAS
> 9.1\\sas.exe\",\"c:\\entropy\\output7\\scale\\syntax.sas\"") :
>
>    "c:\Program Files\SAS\SAS
> 9.1\sas.exe","c:\entropy\output7\scale\syntax.sas" is not be found
>
>
>
> When I try
>
> system('"c:\\Program Files\\SAS\\SAS
> 9.1\\sas.exe"','"c:\\entropy\\output7\\scale\\syntax.sas"')
>
> The warring message is as follow,
>
> The mistake is if (intern) flag<- 3L else { : The argument can not be
> interpreted as the logical value.


See ?shell (and ?system) and find that you need one string such as:

  shell('"c:\\Program Files\\SAS\\SAS 9.1\\sas.exe" 
"c:\\entropy\\output7\\scale\\syntax.sas"')

given the paths are correct.

Uwe Ligges


>
>
> These commands also don't work outside R, but I also don't know how to
> modify.
>
>
>
> I guess it's because I lose a command to tell SAS to read the file, but I
> don't know how to do this.
>
>
>
> Hope it's clear enough.
>
> Can anyone give me some help with this?
>
>
>
> Thanks~
>
>
>
> Yen
>
>
>
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
> Behalf Of Ben Bolker
> Sent: Monday, March 01, 2010 12:32 AM
> To: r-help at stat.math.ethz.ch
> Subject: Re: [R] Calling SAS from R
>
>
>
> Yen Lee<b88207001<at>  ntu.edu.tw>  writes:
>
>
>
>> I apologize if my sentence is not fluent to read.
>
>>
>
>> I am doing a simulation study and I need to execute SAS and
>
>> read a SAS code in R.
>
>> I try the following code but it doesn't work.
>
>> system('"c:\\program files\\SAS\\SAS 9.1\\sas.exe" "c:\\syntax.sas"')
>
>> can anyone give me some help with this?
>
>
>
>    You need to tell us, as precisely as possible,
>
> what "doesn't work" means.
>
>    Did R produce warnings or error messages?  What were they?
>
>    If you run the equivalent command (the same except for
>
> single vs double backslashes and surrounding quotation marks)
>
>
>
> "c:\program files\SAS\SAS 9.1\sas.exe" "c:\syntax.sas"
>
>
>
>    outside of R (in a terminal window or from the "Run" box
>
> in Windows), does it work?
>
>
>
> ______________________________________________
>
> R-help at 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.
>
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.



More information about the R-help mailing list