Drop observations in panel data using Stata

2020-01-20 06:32发布

I have longitudinal data on individuals (id) surveyed in two years. Some individuals were not surveyed the second time. I would like to drop all outcomes on individuals surveyed only once so that I am left with a balanced data set.
How do I do this in Stata?

标签: stata
1条回答
走好不送
2楼-- · 2020-01-20 07:19

This might do it for you:

by id, sort: drop if _N!=2

The by id will execute the command following the colon separately for each value of id, and _N will be the number of observations with that id.

查看更多
登录 后发表回答