Good afternoon! I'm very new to Stata and am having difficulty converting a text value to a numeric one. I have a data set with hospital account types (22 account types under a variable called "accnt_type"), with lengths between 4 and 5 characters long. For example: "O ER" and "I INP" are two of the account types. I used the encode accnt_type, gen(visit_type) command to convert a string variable to a numeric one and create a new variable called visit_type.
Now, I'd like to replace "O ER" and "O OB" values with a 2, the "O OUT" value with a 1, and all of the other visit types with a 0 - where the 0, 1, and 2 appear in the dataset. However, I can't determine how to do this. Can you provide some guidance on this, please? Thank you.
Now, I'd like to replace "O ER" and "O OB" values with a 2, the "O OUT" value with a 1, and all of the other visit types with a 0 - where the 0, 1, and 2 appear in the dataset. However, I can't determine how to do this. Can you provide some guidance on this, please? Thank you.
Comment