Hi there,

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
In this case, firm 2 and 3 will be removed entirely (all four lines of data), and only the data for firm 1 and 4 will remain.

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 
}
Obviously, this is flawed. Any suggestions would be highly appreciated, thanks!