2

我需要合并两个数据集(data1.dta&& data2.dta):merge 1:1 personid using data2

但是我不想包括所有变量data2。有什么方法可以指定 data2我想要包含的变量列表merge吗?

4

1 回答 1

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)
于 2013-05-30T06:18:59.393 回答