Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Creating new variables based on information from three other variables

    I’m having some difficulty creating a new variable from three others.
    All variables are of binary type (values 0 or 1).

    They are a result of an analysis of a set of variables (Like an indicator). For instance:
    gen alerta_rec = a1maoseoupesfrios+ a3noudornoestmago+ a2bocaseca+ a4aumentodesudorese+ a5tensomuscular+ a6apertonamandbula+ a7diarreiapassageira+ a8inosnia+ a9taquicardia+ a10respiracaoofegante+ a11hipertensaosubita+ a12mudancadeapetite+ a13aumentosubitodemotivacao+ a14entusiasmosubito+ a15vontadesubita
    gen alerta_id = alerta_rec
    recode alerta_id 0/6=0 7/max=1
    When I create a table with them, they show this:
    alerta_id n %
    0 101 89.4
    1 12 10.6
    113
    resistencia_id n %
    0 70 61.9
    1 43 38.1
    113
    exaustao_id n %
    0 102 90.3
    1 11 9.7
    113
    I’d like to create a variable which shows the total of individuals that agree with at least one of the three originals items (which would be 66), but it doesn't work!

    gen lipp_status=0
    replace lipp_status=1 if alerta_id==1 | resistencia_id==1 | exaustao_id==1
    tab lipp_status
    lipp_status n %
    0 69 61.1
    1 44 38.9
    113
    How can I solve this?
    Thank you

  • #2
    Welcome to Statalist.

    Your problem is that you have individuals who agree with more than one of the three original items, and for them, they will be counted only once in lipp_status.
    Code:
    list alerta_id esistencia_id exaustao_id if lipp_status==1

    Comment

    Working...
    X