If you look at the last paragraph my previous reply in #14, you will see that this is exactly what I was trying to explain. In the code
the part (tot_brake > 0) is a logical evaluation, which returns true or false -- respectively, 1 or 0.
Your code
is different for the following reasons:
Code:
gen byte max_brake = (tot_brake > 0) if !missing(intervention)
Your code
Code:
gen max_brake = 0 replace max_brake = 1 if tot_brake > 0 if !missing(intervention)
- the first line would produce a value 0 for all observations, including where intervention is missing. I think you want missing values when intervention is missing.
- the second line is illegal; you cannot have two ifs. If you changed it to
Code:
replace max_brake = 1 if tot_brake > 0 & !missing(intervention)
Comment