My problem lies at step 2: when i generate the match dummy with the line starting with by idperson, for all 3800 observations, Stata generates a missing value. I have made dummies before and have tried to make this one in different ways as well, but each time Stata output says: (3,800 missing values generated).
Any help is greatly appreciated,
Olivier
1. With the following code, I created a variable that lists the maximum probability across the 5 labour quantity alternatives for each idcode:
Code:
bysort idcode: egen max_prediction=max(pr)
2. Now I want to create a dummy "match" that equals 1 when the choice alternative for a row (pr) equals max_prediction. In other words, a dummy that equals 1 for the choice alternative with the highest probability across the 5 options.
Code:
by idperson: gen match = 1 if max_prediction==pr replace match=0 if match==.
0 Response to Assigning value "1" to a dummy variable when another variable reaches its max, for each individual across choice alternatives
Post a Comment