Search code examples
if-statementstata

If statement Stata


I'm trying to build the following if statement in Stata: I want Stata to restrict my sample with the following conditions keep if distance > 50 & distance < 60 but only if the binary variable category = 0. How can I achieve this?


Solution

  • You can add an extra condition in your if-statement.

    keep if category == 1 | (category == 0 & distance > 50 & distance < 60)