Announcement

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

  • gen var with only and mixed terms

    Good morning, I have a database with twelve variables (six, positive terms; and six, negative terms). All variables are computed as 0 (no) and 1 (yes).

    I need to create a new variable which classify all respondents between those who only reported positive terms, those who only reported negative terms, and those who reported both). Could someone help me formulating the command?

    Thank you so much,

  • #2
    Code:
    egen mean = rowmean(whatever1-whatever12) 
    
    gen wanted = cond(rowmean == 1, 2, cond(rowmean == 0, 0, 1)) 
    
    label def wanted 2 "all positive" 1 "mixed" 0 "all negative" 
    
    label val wanted wanted
    You may need something more elaborate based on first calculating separate means for positive terms and negative terms.

    Comment

    Working...
    X