dta

Proper phrasing for a loop to convert all .dta files to .csv in a directory

非 Y 不嫁゛ 提交于 2021-01-28 18:44:17
问题 So I have a single instance of dta to csv conversion, and I need to repeat it for all files in a directory. Great help on SO, but I'm still not quite there. Here's the single instance #Load Foreign Library library(foreign) ## Set working directory in which dtw files can be found) setwd("~/Desktop") ## Single File Convert write.csv(read.dta("example.dta"), file = "example.csv") From here, I figure I use something like: ## Get list of all the files file_list<-dir(pattern = ".dta$", recursive=F,

Convert .CSV files to .DTA files in Python

依然范特西╮ 提交于 2020-01-11 11:58:12
问题 I'm looking to automate the process of converting many .CSV files into .DTA files via Python. .DTA files is the filetype that is handled by the Stata Statistics language. I have not been able to find a way to go about doing this, however. The R language has write(.dta) which allows a dataFrame in R to be converted to a .dta file, and there is a port to the R language from Python via RPy, but I can't figure out how to use RPy to access the write(.dta) function in R. Any ideas? 回答1: You need

Importing foreign languages from csv file to Stata

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-22 10:15:51
问题 I am using Stata 12. I have encountered the following problems. I am importing a bunch of .csv files to Stata using the insheet command. The datasets may conclude Russian, Croatian, Turkish, etc. I think they are encoded in "UTF-8". In .csv files, they are correct. After I imported them into Stata, the original strings are incorrect and become the strange characters. Would you please help me with that? Does Stat-Transfer can solve the problems? Does it support .csv format? For example, the

Efficiently construct Pandas DataFrame from large list of tuples/rows

荒凉一梦 提交于 2019-12-18 12:53:11
问题 I've inherited a data file saved in the Stata .dta format. I can load it in with scikits.statsmodels genfromdta() function. This puts my data into a 1-dimensional NumPy array, where each entry is a row of data, stored in a 24-tuple. In [2]: st_time = time.time(); initialload = sm.iolib.genfromdta("/home/myfile.dta"); ed_time = time.time(); print (ed_time - st_time) 666.523324013 In [3]: type(initialload) Out[3]: numpy.ndarray In [4]: initialload.shape Out[4]: (4809584,) In [5]: initialload[0]

Using memisc to import stata .dta file into R

℡╲_俬逩灬. 提交于 2019-12-10 13:49:10
问题 I have a 700mb .dta Stata file with 28 million observations and 14 column variables When I attempt to import into R using foreign's read.dta() function I run out of RAM on my 8GB machine (page outs shoot into GBs very quickly). staph <- read.dta("Staph_1999_2010.dta") I hunted around and it sounds like a more efficient alternative would be to use the Stata.file() function from the memisc package. When I call: staph <- Stata.file("Staph_1999_2010.dta") I get a segfault: *** caught segfault ***

Importing foreign languages from csv file to Stata

浪子不回头ぞ 提交于 2019-12-05 22:04:08
I am using Stata 12. I have encountered the following problems. I am importing a bunch of .csv files to Stata using the insheet command. The datasets may conclude Russian, Croatian, Turkish, etc. I think they are encoded in "UTF-8". In .csv files, they are correct. After I imported them into Stata, the original strings are incorrect and become the strange characters. Would you please help me with that? Does Stat-Transfer can solve the problems? Does it support .csv format? For example, the original file is like: My code is like: insheet using name.csv, c n save name.dta,replace The result is