I am trying to write a code with Stata to extract a single section of a string variable based on a hierarchy rule.
For example, let's define the hierarchy in order of decreasing importance, the following colours: red, green, blue
If I have the following entries under variable name "colour":
red
red; green
green; blue
blue; red
blue
I would like the output variable to be the following:
red
red
green
red
blue
Many thanks in advance for your help
For example, let's define the hierarchy in order of decreasing importance, the following colours: red, green, blue
If I have the following entries under variable name "colour":
red
red; green
green; blue
blue; red
blue
I would like the output variable to be the following:
red
red
green
red
blue
Many thanks in advance for your help
Comment