Skip to content

Instantly share code, notes, and snippets.

@Jianghao
Last active August 29, 2015 14:23
Show Gist options
  • Save Jianghao/cf883b15b9148a9982f8 to your computer and use it in GitHub Desktop.
Save Jianghao/cf883b15b9148a9982f8 to your computer and use it in GitHub Desktop.
read stata 13 data files
setwd("D:/Cooperation/Caojing/Geocoding/")
# library(foreign)
# data <- read.dta("pollution_cen.dta")
# ## not a Stata version 5-12 .dta file
## on windows only
install.packages("haven")
require(haven)
df <- read_dta('pollution_cen.dta')
for(i in 1:ncol(df)){
df[,i] <- iconv(df[,i], to="gbk")
}
write.csv(df, "pollution_cen.csv", row.names = F, fileEncoding = "GBK")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment