Announcement

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

  • Summing across variables

    I have data with 160 countries and 6 sectors as variable names. I tried to use the foreach command to sum the six sectors of each country so I get 160 countries using

    foreach var of varlist AFG1-ZWE6 {
    egen `var'_FD = rowtotal (`var'*)
    }

    But this command just repeats the same variables and does not sum all the six sectors for each country. Could someone please help write the command well? Thanks in advance

  • #2
    Duplicate post. If interested please follow the thread at https://www.statalist.org/forums/for...ross-variables

    Marin: Please don't do this. https://www.statalist.org/forums/help#adviceextras #1 explains about bumping (summary of advice: don't).

    Comment

    Working...
    X