我需要合并两个数据集(data1.dta
&& data2.dta
):merge 1:1 personid using data2
但我不想包含data2
的所有变量。有没有办法指定我想要包含在data2
中的merge
变量列表?
答案 0 :(得分:1)
您可以使用keep
:
// saving `data2` under a different name
...
save temporary
keep personid var1 var2 //list here all variables that you want to keep
merge 1:1 personid using temporary
erase temporary
// done!
或者就是这样:
// var1 var2 etc. are the variables that you want to keep
merge 1:1 personid using temporary, keepusing(var1 var2)