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 18:05:54 +0000 (GMT)

Thanks Nick. I tried several things given below, but I still cannot get "18825 changes made" in total, they are the people without work limiting disability. Can I please ask what precisely needs to be issued to get the "18825 or 18826 changes made" please.
 
Thanking You
 
 ge disabledworklim=.
(22451 missing values generated)
. replace disabledworklim=1 if e6a==1&e6b==1
(997 real changes made)
. replace disabledworklim=2 if (e6a==2)&(e6a==1-e6b==1)
(17174 real changes made)
. replace disabledworklim=2 if (e6a==1&2)-(e6b==1)
(1700 real changes made)
. replace disabledworklim=2 if (e6a==1&e6a==2)&-(e6b==1)
(0 real changes made)
. replace disabledworklim=2 if (e6a==1&e6a==2)-(e6b==1)
(997 real changes made)
. replace disabledworklim=2 if (e6a<=e6a==1)&(e6a==1<=e6a==2)
(0 real changes made)
. replace disabledworklim=2 if (e6b<=e6a==1)&(e6a==1<=e6a==2)
(0 real changes made)

Nick wrote:
 
I think you need two & operators. No logical operator 
can be given implicitly. Parenthesising aggressively
would do no harm either. 
So, for example, there is no Stata equivalent 
of 
a <= x <= b 
except (a <= x) & (x <= b) 
Nick 
[email protected] 
 
 
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/6 changes made total", that is from e6a==2+(e6a==1-e6b==1)= 17,174+(2673-1021)=1652 which is =18826
.replace disabledwklim=2 if e6a==2&e6a==1-e6b==1
(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