I have a firm-level data for two years. I want to drop a firm entirely (both years' observations) if there is missing value in any one year for any one of the three variables, var1, var2, and var3.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input byte(id year var1 var2 var3) 1 1 17 1 3 1 2 19 1 3 2 1 20 0 3 2 2 35 1 . 3 1 . 0 1 3 2 18 0 5 4 1 19 1 4 4 2 14 0 2 end
I was going for something like:
Code:
foreach var in var1 var2 var3 { drop _n _n+1 if missing(`v') & year==1 drop _n _n-1 if missing (`v') & year==2 }
0 Response to Dropping all panel observations if any one of them have missing value for any one of the variables
Post a Comment