@altadata1 wrote:
Thank you for your response @PaigeMiller. In my case, I'd like to create two new variables like this:
when tag is between A00 and B90, if tag equals to A23, B19, B21, then new_var=1, the rest new_var_2=2.
Many thanks again.
This is a relatively simple change to the code I provided, and I leave it to you as a homework assignment to make the change.
Since these two conditions are mutually exclusive, I recommend putting both conditions into one single variable, as I did, rather than two variables, unless you have a very good reason why it needs to be in separate variables. If there are two and only two values that a variable can take on, 0 and 1 is recommended and preferred over 1 and 2.
... View more