Announcement

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

  • Is there a simpler way of doing this?

    Hi,
    Currently doing a dissertation using stata. First time using the software, not very familiar with it. I'm trying to create a variable that sums ~18 of the 32 total variables, but it can't be a simple add them all up command. Long story short, the data is base 1 while >0. So if it's less than 1, this needs to be made clear. Ive come up with a very rudimentary command (seen below)but was wondering if there's a way to simplify this. Thanks

    gen Specialisation = ((1-Mining)+(1-Manufacturing)+(1-Electricity)+(1-Sewage)+(1-Construction)+(1-Retail)+(1-Transport)+(1-Hospitality)+(1-Information)+(1-Finance)+(1-Real_Estate)+(1-Research)+(1-Administration)+(1-Defence)+(1-Education)+(1-Social_Care)+(1-Recreation)+(1-Others))/18

  • #2
    Code:
    generate double Specialisation = 1 - (Mining+Manufacturing+Electricity+Sewage+Construction+ ///
    Retail+Transport+Hospitality+Information+Finance+Real_Estate+Research+ ///
    Administration+Defence+Education+Social_Care+Recreation+Others)/18
    See also help for egen rowtotal().
    Mind the missing values (if relevant).

    Comment


    • #3
      Thanks!

      Comment

      Working...
      X