Reputation: 185
I am merging two datasets in Stata, both of which have more than 300
variables. Upon merging, I learned that the two datasets have at least 20
variables in common - some are strings in one dataset, and floats in others.
Does anyone know of a simple way to find out how many other variables the datasets have in common without merging first?
I know that I can, for example, add a prefix to variable names in one dataset and then compare the variables once the datasets are merged, but I was wondering if there was a faster way to do this. Like some sort of list that simply identifies a list of the common variables.
Upvotes: 0
Views: 391
Reputation: 185
Answer based on advice from @NickCox:
describe using StateWelfareData.dta, varlist
local welfare `r(varlist)'
clear
describe using StatePolicyData.dta, varlist
local merged `r(varlist)' `welfare'
local duplicates: list dups merged
display "`duplicates'"
Upvotes: 2