Logistic regression in Stata with binomial dependent variable 3-level categorical predictor variable


I'm doing a logistic regression analysis with a binomial outcome variable (Yes / No). My main predictor variable is categorical and has 3 levels. I'm also including categorical and continuous confounding variables as predictors. What is the best way to convert my outcome variable from string (Y / N) to numeric (0 / 1)? I've been using the encode var, generate(var_new) command; however, this generates a column with 1s and 2s, which is not usable in logistic regression. I've used replace var_new = var_new - 1 but it seems like there should be a more straightforward way to do this.

What is the appropriate way to code a dependent variable for logistic regression?

Last edited: