Skip to content

Converting a list from R to Stata

2 messages · Vicky Landsman, Thomas Lumley

#
Dear all,
I have a list containing 150 simulated datasets in R. Is there a way to 
convert it to the Stata format such that I will be able to apply some Stata 
functions on each dataset in the list?
Thank you in advance,
Vicky Landsman.
#
On Wed, 3 Aug 2005, Vicky Landsman wrote:

            
For Stata your best best is probably to stack all 150 datasets into one 
long data frame and add an id variable, so you can then -by id:- your 
analysis.
   big.data.frame <- do.call("rbind", the.list.of.datasets)
will stack them for you and
   big.data.frame$id <- rep(1:150, sapply(the.list.of.data.sets, nrow))
will make the id variable.

 	-thomas