I am new to Stata and trying to undertake a task for a stat class.
I have a dataset containing two waves of a survey, and I want to keep only observations available in both wave1 and wave2.
Please see below for an example of the data.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input long hhid double hhpid byte indiv float wave byte sex 10001 1000103 3 2 1 10001 1000108 8 2 0 10002 1000203 3 1 0 10002 1000208 8 2 1 10002 1000209 9 2 1 10003 1000303 3 1 0 10003 1000304 4 1 1 10003 1000305 5 1 0 10003 1000306 6 1 0 10003 1000306 6 2 0 10004 1000405 5 2 1 10005 1000503 3 2 0 10005 1000504 4 2 1 10005 1000505 5 2 1 10008 1000804 4 1 1 10008 1000805 5 1 1 10008 1000806 6 1 0 10008 1000807 7 1 1 10008 1000807 7 2 1 10008 1000808 8 2 0 10009 1000903 3 2 1 10009 1000905 5 2 1 10009 1000906 6 2 1 10010 1001004 4 1 1 10011 1001105 5 1 0 10011 1001106 6 1 1 10013 1001308 8 1 1 10016 1001603 3 1 1 end label values sex sex label def sex 0 "0. Male", modify label def sex 1 "1. Female", modify
0 Response to Dropping observations if entity does not exist in both waves
Post a Comment