If the string variable contains anything but numbers, you can add the force option to tell Stata to convert it anyway, but observations with any non-numeric characters will get a missing value.
STATA EGEN FREE
Stata's flagship input command to read raw data is infile, which can deal with both: – Free Format Data:.These are the infile command, the import delimited and the infix command. In Stata we can state something as true like below: use the dummy variable without explicitly specifying the condition but with the variable name alone. You can’t do any statistical Stata Tutorial Princeton University. Alternatively, you may also specify e (name) or r (name) to tabulate an e () -matrix or an r () -matrix. Remember, this is kind of complicated, so it takes a bit of time to get used to all the concepts, and if I'm using strong language it's not to mock you but just to try to clarify things.You could do everything it does with regular expressions if you reeeally wanted to, but it makes the whole process a bit easier. There's a divergence between what you are telling Stata to do, and what you should want to do (as far as we can infer from your writing). Anyway, this is not what you actually want to do. It's just that you are effectively just asking what's the average cost if the house is open, and ignoring other houses. I say this not to mock you, because we've all been there. When you type regress cost if open = 1, you're asking a pointless question. Never mind any other explanatory variables for now. In plain English, you want to use regression to test if being open has an effect on the mean cost. You imply that you want to regress cost on being open. The first two you could really just do in Excel if you wanted.
STATA EGEN PLUS
Right now, this is a bit like just asking: what's the average cost for closed houses that are closed, and the average cost for open houses, plus a statistical test. Basically, we are saying that you should just type regress cost i.open. Your statements in the paragraph are contradictory. I want to regress the two only when open is 1. I have a dummy variable for whether a house is open or not, open being 1. In this case, the constant term will be the sample mean of those houses that are NOT open and the coefficient on open would be the difference in the sample mean of houses that are open and those that are not.Ĭonveniently, if you add the constant term and the parameter on open you will find the same value (within rounding) of the parameter you obtained using your original regressionĬredentials: Economics Ph.D., have taught econometrics for 25 years Notice that there is no conditional statement at the end of the reg command. In that case, you would include all of the observations in your sample and add the open variable as a regressor, e.g., If not, perhaps what you want to investigate is how the variable cost changes between houses that are "open" and those that are not. It is the mean of cost for the sample of observations for which the dummy variable open equals one.Īre there any other explanatory variables you wish to include? The regression command you have entered asks Stata to estimate the regression including only a constant term, which is what you see in the output.