Drop observations in panel data using Stata

自闭症网瘾萝莉.ら 提交于 2019-12-13 22:30:25

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/36926272/drop-observations-in-panel-data-using-stata

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!