Forvalue Stata. Then i categorize using gen kat. One common pattern is to cycle through all values of a classifying variable.
Foreach i in 0 1. For offers one way of repeating one or more stata commands. For num 0 1.
For offers one way of repeating one or more stata commands.
Description forvalues repeatedly sets local macro lname to each element of range and executes the commands enclosed in braces. The loop is executed zero or more times. You will need to distinguish how you want to count through the number sequence. How about something like this.