Hi All
I'm creating a variable named score1982 that should show the total number of conditions a subject has (of a possible max of 10). All ten variables are binary (coded as 0/1).
However, I don't seem to be getting the right total score for many subjects. For example, subject ID 11 only has one condition coded as '1' (resp1982) but has a total score of 2. Same problem with ID 15. I've cross-checked all the data prep and as far as I can see all variables are coded as 0 or 1.
Only, a subset of the data visible here:
Any help will be much appreciated!
Thanks
/Amal
I'm creating a variable named score1982 that should show the total number of conditions a subject has (of a possible max of 10). All ten variables are binary (coded as 0/1).
However, I don't seem to be getting the right total score for many subjects. For example, subject ID 11 only has one condition coded as '1' (resp1982) but has a total score of 2. Same problem with ID 15. I've cross-checked all the data prep and as far as I can see all variables are coded as 0 or 1.
Code:
egen score1982 = rowtotal(obesity1982 ht1982 derm1982 resp1982 kidney1982 gi1982 psychosis1982 mental1982 epi1982 cancer1982 resp1982) tab score1982 br NSHD_ID obesity1982 ht1982 derm1982 resp1982 kidney1982 gi1982 psychosis1982 mental1982 epi1982 cancer1982 resp1982 score1982
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input int ID float(obesity1982 ht1982 derm1982 resp1982) int kidney1982 float(gi1982 psychosis1982 mental1982 epi1982 cancer1982 score1982) 1 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 3 . . . . . . . . . 0 0 4 . . . . . . . . . 0 0 5 0 0 0 0 0 0 0 0 0 0 0 6 . . . . . . . . . 0 0 7 0 0 0 0 0 0 0 0 0 0 0 8 . . . . . . . . . 0 0 9 0 0 0 0 0 0 0 1 0 0 1 10 1 0 0 0 0 0 0 0 0 0 1 11 0 0 0 1 0 0 0 0 0 0 2 12 . . . . . . . . . 0 0 13 . . . . . . . . . 0 0 14 0 0 0 0 0 0 0 0 0 0 0 15 0 0 0 1 0 0 0 0 0 0 2 16 . . . . . . . . . 0 0 17 0 0 0 0 0 0 0 0 0 0 0 18 . . . . . . . . . 0 0 19 . . . . . . . . . 0 0 20 0 0 0 0 0 0 0 0 0 0 0 21 0 0 0 0 0 0 0 0 0 0 0 22 0 0 0 0 0 0 0 0 0 0 0 23 . . . . . . . . . 0 0 24 0 0 0 0 0 0 0 0 0 0 0 25 0 0 1 0 0 0 0 0 0 0 1 26 . . . . . . . . . 0 0 27 . . . . . . . . . 0 0 28 . . . . . . . . . 0 0 29 0 0 0 0 0 0 0 0 0 0 0 30 0 0 0 0 0 0 0 0 0 0 0 end
Thanks
/Amal
Comment