I want to write
but this errors out when g0 == 1 (since it tries to access v[g0-1] which is out of subscript bounds).
I guess this is something Stata users commonly have to deal with. What do you do? I think I'll just put a double if
since my code happens to be on one line, but that does not seem like a good general approach.
Reference: https://en.wikipedia.org/wiki/Short-circuit_evaluation
Code:
if (g0 > 1 & v[g0] - v[g0-1] >= 5 ) ...
I guess this is something Stata users commonly have to deal with. What do you do? I think I'll just put a double if
Code:
if (g0 > 1) if (v[g0] - v[g0-1] >= 5 ) ...
Reference: https://en.wikipedia.org/wiki/Short-circuit_evaluation