lbraglia / RStata

[R package]: A R-Stata interface
112 stars 37 forks source link

Cannot connect to Stata (Windows) #32

Open cchen-ops opened 1 year ago

cchen-ops commented 1 year ago

I have tried multiple variations of my Stata path. (i) I've pasted it directly from the file folder (ii) tried it with the executable name and without (iii) tried it with and without .exe., (iv) with and without administrator rights for Rstudio. I keep getting error

Error in file(con, "r") : cannot open the connection In addition: Warning message: In file(con, "r") : cannot open file 'RStata.log': No such file or directory

Is this a Stata 17 issue? I'm currently using Stata-SE

BeaLeydier commented 1 year ago

Hello! I have the same exact issue and error. I have both Stata17 and Stata16 installed, and tried with both. I am working with R version 4.3.0 and I am on Windows.

See below the code I am running (I have also tried the same with version 16 and the corresponding file path)

library(RStata)
setwd("C:/Users/bl517/Documents/Github/ReBuild_Uganda")
options("RStata.StataPath" = "C:/Program Files/Stata17/StataSE-64")
options("RStata.StataVersion" = 17)
stata("0_scripts/0.9.Compile-Baseline.do")

The error message I am getting is

Error in file(con, "r") : cannot open the connection
In addition: Warning messages:
1: In readLines(SRC[1L]) :
  incomplete final line found on '0_scripts/0.9.Compile-Baseline.do'
2: In file(con, "r") :
  cannot open file 'RStata.log': No such file or directory

Any help is appreciated!

cchen-ops commented 1 year ago

I was eventually able to get it resolved. I was using a group license, and I re-entered the registration information.

This is also how I linked it.

options("RStata.StataPath" = "\"C:\\Program Files\\Stata17\\StataSE-64\"")
options("RStata.StataVersion" = 17)
kalebsm commented 1 year ago

Hello,

I have run into the same issue, run a similar bit of code as cchen-ops, and run into an issue where Stata is trying to read the RStata.log directly in C:\Windows, as per the attachment.

How can I resolve this and run Stata through R?

image

kalebsm commented 1 year ago

@cchen-ops how do you re-enter the registration information? would that solve the issue of RStata.log?

xiaoming-room commented 12 months ago

I run into the same issue. How do you re-enter the registration information? would that solve the issue of RStata.log? @cchen-ops