Hello
I am new to Stata, and need some help.
I have a problem with finding the correct command to generate a binary variable using three different numeric variables.
My dataset contains 167 observations. For one observation, there is three different numeric variables. The values of these variables represent the same answer (so 1 in var1 is the same as 1 in var2). For each of the variables there are three values, 1, 2 and 4.
What I am looking for is how to generate binary variables where all values = 1 is summarized regardless of which variable it came from. Something like this:
- sum_cvk_place1: value 1 = sum of ALL values = 1 in both var1 + var2 + var3. 0 = ALL values in var 1 + var 2 + var 3 not being = 1
- sum cvk_place2: value 2 = sum of all values = 2 in both var1 + var2 + var3. 0 = ALL values in var1 + var2 + var3 not being = 2
- sum cvk_place3: value 3 = sum of all values = 4 in both var1 + var2 + var3. 0 = ALL values in var1 + var2 + var3 not being = 4
Missing values is not to be included.
Thank you
I am new to Stata, and need some help.
I have a problem with finding the correct command to generate a binary variable using three different numeric variables.
My dataset contains 167 observations. For one observation, there is three different numeric variables. The values of these variables represent the same answer (so 1 in var1 is the same as 1 in var2). For each of the variables there are three values, 1, 2 and 4.
What I am looking for is how to generate binary variables where all values = 1 is summarized regardless of which variable it came from. Something like this:
- sum_cvk_place1: value 1 = sum of ALL values = 1 in both var1 + var2 + var3. 0 = ALL values in var 1 + var 2 + var 3 not being = 1
- sum cvk_place2: value 2 = sum of all values = 2 in both var1 + var2 + var3. 0 = ALL values in var1 + var2 + var3 not being = 2
- sum cvk_place3: value 3 = sum of all values = 4 in both var1 + var2 + var3. 0 = ALL values in var1 + var2 + var3 not being = 4
Missing values is not to be included.
Thank you
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input byte(cvk_place cvk_place_v2 cvk_place_v3) 1 4 1 1 . . 1 2 . 1 . . 1 . . 1 . . 1 . . 1 . . 1 . . 2 . . 1 1 . 1 . . 1 . . 1 . . 1 . . 1 . . 4 2 . 1 . . 1 . . 1 1 2 end label values cvk_place cvk_place_ label def cvk_place_ 1 "V.jugularis", modify label def cvk_place_ 2 "V.subclavia", modify label values cvk_place_v2 cvk_place_v2_ label def cvk_place_v2_ 1 "V.jugularis", modify label def cvk_place_v2_ 2 "V.subclavia", modify label values cvk_place_v3 cvk_place_v3_ label def cvk_place_v3_ 1 "V.jugularis", modify label def cvk_place_v3_ 2 "V.subclavia", modify
Comment