Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Re: Calling SAS and R code from Stata


From   n p <nik_padazis@yahoo.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Re: Calling SAS and R code from Stata
Date   Tue, 2 May 2006 08:05:09 -0700 (PDT)

I dont know if that's the best way but here's what I
do:
********************************
...Stata code...
save myStataFile,replace

winexec "C:\Program Files\R\rw2010\bin\R.exe" CMD
BATCH "c:\\...\\program_in_R.r" 
"c:\\...\\results_from_R.txt"

... Stata code continues possibly reading results from
R_results.dta (see below)
*************************************


R can read and write Stata files so your R code could
look like this :


library(foreign)
test<-read.dta("c:\\...\\myStataFile.dta")
... R code ...
write.dta(as.data.frame(mod1$coefficients$fixed),"c:\\...\\R_results.dta")


 I hope this helps

Nikos Pantazis
Biostatistician, MSc

--- Babak Oskooei <babak_cho@yahoo.com> wrote:

> Dear Statalist,
> 
> I have a question regarding STATA software.
> I would appreciate any comments on the following
> problem:
> 
> I perform research on several measures of explained
> variation in survival analysis which were programmed
> in different software such as SAS, R and C. I am
> planning to conduct simulation studies on all these
> measures in STATA software. Considering the deadline
> I
> have, it is practically impossible for me to program
> all measures again in STATA. I was wondering whether
> these programs could be run from within STATA. I
> know
> that STATA allows you to call in C codes using
> Plugin
> facility that exist in STATA, but I do not know
> whether this is possible with SAS or R code. Is it
> possible to use SAS or R as slave programs? 
> 
> I would be grateful for any comments on this or any
> references that I can refer to.
> 
> Best regards
> 
> Babak Oskooei
> PhD Student
> UCL Statistical Sciences Dep.
> 
> 

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index