I realise that there are already a bunch of topics out there on merging datasets, but I just started using R and I have difficulty understanding some of the answers given, especially when I try to apply them to my own specific situation.
I have around 80 STATA datasets that I want to merge, they all got the variables var1 and var2 in common, but can differ in other variables (and the number of variables). So I read that I need to create a list of my datasets first, when creating a list of foreign datasets, do I also need to read them into R using read.dta
?
I'm trying to do this by:
temp = list.files(pattern="*.dta")
#Loop through all of the databases
for (i in 1:length(temp)) {
list <- read.dta13(temp[i], nonint.factors = TRUE)
}
But I'm getting the feeling that I'm doing this wrong.
Once I got a list of databases, do I then use merge_all(list, by=c("var1","var2))
?