I'd like to ask for advice.
I have the following data:
I want to make a "var2" using "var1".
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float(id var1 var2) 1 1 0 1 1 0 1 1 0 2 0 0 2 0 0 2 0 0 3 0 1 3 1 1 3 1 1 4 1 1 4 0 1 4 1 1 end
The conditions for making var2 are as follows.
If id has only 1 or 0 value in var1, var2 must be 0.
If id has both 1 and 0 in var1, var2 must be 1.
Thank you!
0 Response to Create a new column using a column of 1 and 0.
Post a Comment