I have a small dataset as follows,
clear
input sid year sign
1 1 0
1 2 0
1 3 0
1 4 0
1 5 0
1 6 0
1 7 0
2 1 1
2 2 0
2 3 0
2 4 0
2 5 0
2 6 0
2 7 0
3 1 1
3 2 1
3 3 1
3 4 1
3 5 1
3 6 1
3 7 1
end
I want to remove the observations if all the values of sign variable are 0 within group (sid).
In other words, I want to keep the data if year==1 & sign==1
Could you help me with Stata code?
Thank you!
clear
input sid year sign
1 1 0
1 2 0
1 3 0
1 4 0
1 5 0
1 6 0
1 7 0
2 1 1
2 2 0
2 3 0
2 4 0
2 5 0
2 6 0
2 7 0
3 1 1
3 2 1
3 3 1
3 4 1
3 5 1
3 6 1
3 7 1
end
I want to remove the observations if all the values of sign variable are 0 within group (sid).
In other words, I want to keep the data if year==1 & sign==1
Could you help me with Stata code?
Thank you!

Comment