* Branchingsysuse auto, clearcount if foreign == 0// Count all domestic car models.local obs = r(N) // Use the scalar containing the number of observations, created by "count"if`obs' >= 10 { // Execute if there are at least 10 domestic car models. Execute, if this condition is true. sum price if foreign == 0
}
else { // Execute if there are less than 10 domestic car models. - Can only be executed after if-condition. sum price if foreign == 1
}
* Branching with nestingsysuse auto, clearcount if foreign == 0local obs = r(N)
if`obs' >= 10 { // Execute if there are at least 10 domestic car models. if price[3] >= 1000 { // Execute if the price of the car in observation 3 is at least 1000 US-$. sum price
}
}