I'm having a hard time generating dummy variables using a for loop. I have a variable with some values, now I want to create a dummy variable for each value such that if it takes the specific value it will return 1 otherwise it will return 0. I can't make it work since I always end up creating one new variable with all values being equal to 1. I have posted two pictures, the first one is the variable and the second one is how I want it to look like.
Array
I want it to look like this:
Array
Related Posts with Use a for-loop to generate dummy variables
System GMM with a set of endogenous dummy variables and their coefficientsHi all: I am using xtabond2 to estimate system GMM. My main interest variable is not lagged depende…
Convert string variable to a date variableDear Stata Users I have a string variable yearmonth: for Jan 2004 it's stored as "200401". I need t…
Can we determine the significance of changes over time using cross-sectional data?Dear Statalisters, I am using data from the 2011 and 2014 Demographic Health Surveys (these are rep…
Converting continuous variable into categoricalHi, I am new to STATA and would really appreciate if someone could advise me on the following: I wou…
Interpretation of logit coefficients and rescaling of variablesDear all, I am trying interpret the coefficient of logistic regression results and would very much …
Subscribe to:
Post Comments (Atom)
0 Response to Use a for-loop to generate dummy variables
Post a Comment