Dear All
I am looking to create a new categorical variable based on two existing ones. Typically, this would be egen ... group. However, in this case, an adjustment is needed.
These are the data:
and this is the code used
cat yields the expected result. Now, I am looking for a way to ensure that the order of values in var1 and var2 does not matter, i.e. cat should be == 1 for both ARG & CHL in row 1, as well as for CHL & AGR in row 4.
How can I accomplish this?
Many thanks!
I am looking to create a new categorical variable based on two existing ones. Typically, this would be egen ... group. However, in this case, an adjustment is needed.
These are the data:
HTML Code:
cat var1 var2 1 ARG CHL 2 ARG UKR 3 ARG USA 4 CHL ARG 5 CHL CHL 6 CHL USA 7 UKR ARG 8 UKR CHL 9 UKR USA 10 USA ARG 11 USA CHL 12 USA UKR
Code:
egen cat= group(var1 var2)
How can I accomplish this?
Many thanks!
Comment