Skip to Content

looping in R using stata data

I would like to make a loop with the below codes.

library(foreign)
 library(frontier)
 
d10<- read.dta("manu1_10.dta")
 require(plm)
 manu1_10<-plm.data(d1, c("id","year"))
 re2_10<-sfa(log(y3) ~ log(x1) + log(x2), data=manu1_10, timeEffect=TRUE)
 summary(re2_10)
 efficiencies(re2_10)
 
d11<- read.dta("manu1_11.dta")
 require(plm)
 manu1_11<-plm.data(d2, c("id","year"))
 re2_11<-sfa(log(y3) ~ log(x1) + log(x2), data=manu1_11, timeEffect=TRUE)
 summary(re2_11)
 efficiencies(re2_11)
 
d12<- read.dta("manu1_12.dta")
 require(plm)
 manu1_12<-plm.data(d3, c("id","year"))
 re2_12<-sfa(log(y3) ~ log(x1) + log(x2), data=manu1_12, timeEffect=TRUE)
 summary(re2_12)
 efficiencies(re2_12)
 
d13<- read.dta("manu1_13.dta")
 require(plm)
 manu1_13<-plm.data(d4, c("id","year"))
 re2_13<-sfa(log(y3) ~ log(x1) + log(x2), data=manu1_13, timeEffect=TRUE)
 summary(re2_13)
 efficiencies(re1_13)

Due to "", it is not easy to make a loop. Please let me know how to do it. Thank you.