I have several questions, I hope someone can help me with some or all:
1. I would like to add a requirement in my dataset that every company has minimal 5 observations (5 years of observations). I want Stata to drop the data for the companies that do not meet this requirement. How can I add such a requirement?
2. How can I add a requirement in Stata that all control variables need to be non-missing? The command drop if missing (variables) is not giving me the desired outcome, so is there maybe another way?
3. I would like to have a dummy variable which should be equal to 1 if variable X or/and variable Y are greater than 0, and it should equal 0 if variable X AND variable Y are not greater than 0. How can I include two variables in the dummy requirement or how can I combine two dummies to make it one? I did: gen newvariable = (variable>0) I did this for both variables separately, but I would like to have only 1 dummy.
4. Also about the dummies: when there is a missing value, I would like the dummy to be also missing. However, now if I use the command gen newvariable = (variable>0) all missing values result in dummy = 1. I found already the command gen newvariable = (variable>0) if variable< but that does not work, Stata gives me "invalid syntax".
I hope somebody can help me with this, thanks in advance!
1. I would like to add a requirement in my dataset that every company has minimal 5 observations (5 years of observations). I want Stata to drop the data for the companies that do not meet this requirement. How can I add such a requirement?
2. How can I add a requirement in Stata that all control variables need to be non-missing? The command drop if missing (variables) is not giving me the desired outcome, so is there maybe another way?
3. I would like to have a dummy variable which should be equal to 1 if variable X or/and variable Y are greater than 0, and it should equal 0 if variable X AND variable Y are not greater than 0. How can I include two variables in the dummy requirement or how can I combine two dummies to make it one? I did: gen newvariable = (variable>0) I did this for both variables separately, but I would like to have only 1 dummy.
4. Also about the dummies: when there is a missing value, I would like the dummy to be also missing. However, now if I use the command gen newvariable = (variable>0) all missing values result in dummy = 1. I found already the command gen newvariable = (variable>0) if variable< but that does not work, Stata gives me "invalid syntax".
I hope somebody can help me with this, thanks in advance!

Comment