Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: generate variable


From   peter harper <[email protected]>
To   [email protected]
Subject   st: generate variable
Date   Sat, 27 May 2006 16:37:47 +0000 (GMT)

Dear Statalist
 
I am trying to code in stata the number of people with work limiting disability. I have two variables in my dataset relating to disability.
 
.tab e6a 
 
   do you have any long-term |
  illness, health problem or |
                 disability? by l |      Freq.     Percent        Cum.
-----------------------------+-----------------------------------
              not answered (9) |        208        0.93        0.93
                                 yes |      2,673       11.91       12.83
                                   no |     17,174       76.50       89.33
e6a not yes but e6b answered |  2,387       10.63       99.96
  e6a blank but e6b answered |         9        0.04      100.00
-----------------------------+-----------------------------------
                                Total |     22,451      100.00

. ta e6b
 
  does this illness |
      or disability |
  affect the amount |
   or type  of work |
                    you |      Freq.     Percent        Cum.
--------------------+-----------------------------------
 not answered (9) |        37        0.16        0.16
    multi-coded (7) |          4        0.02        0.18
item not applicable |  17,382       77.42       77.60
                    yes |      1,021        4.55       82.15
                      no |      4,007       17.85      100.00
--------------------+-----------------------------------
                  Total |     22,451      100.00

 
 
. tab e6a e6b
 
  do you have any |
   long-term illness, |  does this illness or disability affect the amount or
    health problem or |                   type  of work you
     disability? by l | not answe  multi-cod  item not         yes         no |     Total
----------------------+-------------------------------------------------------+----------
     not answered (9) |         0          0        208                   0          0 |       208 
                        yes |        22          3          0              997      1,651 |     2,673 
                          no |         0          0     17,174                 0          0 |    17,174 
e6a not yes but e6b a |      15          1          0               20      2,351 |     2,387 
e6a blank but e6b ans |       0          0          0                   4          5 |         9 
----------------------+-------------------------------------------------------+----------
                      Total |        37          4     17,382         1,021      4,007 |    22,451 
 
When I issued
 
.ge disabledwklim=.
 
.replace disabledwklim=1 if e6a==1&e6b==1
997 changes made
 
(this is correct). But when I issued the following command I cannot obtain "18825 changes made total", that is from e6a==2+(e6a==1-e6b==2)= 17,174+1651 which is =18825
 
.replace disabledwklim=2 if e6a==2&e6a==1-e6b==2
(no changes made)
 
I would be grateful if anyone would let me know the correct command for the second replace above.
 
Thanks in advance
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index