Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
Mitch Abdon <mitchaabdon@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: Creating a variable from several "subvariables" |

Date |
Sat, 4 Dec 2010 21:12:57 +0800 |

Your code will give you the sum of x1 for each group defined by x1-x12 To illustrate, try this using auto.dta: sysuse auto egen rsum=total( gear_ratio), by(foreign) the following is the same as the -rsum- egen x_total=rowtotal(x_1-x_12) On Sat, Dec 4, 2010 at 9:01 PM, M.P.J. van Zaal <Matthias.vanZaal@student.uva.nl> wrote: > Your method works allright. > > But i just figured out a different method > > "egen x_total=total(x1), by(x1- x12)" > > > The methods give slightly different results. Which method would be the > correct approach? > > ----- Original Message ----- > From: Mitch Abdon <mitchaabdon@gmail.com> > Date: Saturday, December 4, 2010 1:55 pm > Subject: Re: st: Creating a variable from several "subvariables" > To: statalist@hsphsun2.harvard.edu > >> egen x_total=rsum(x_1-x_12) //assuming that the variables are >> in order >> >> On Sat, Dec 4, 2010 at 8:43 PM, M.P.J. van Zaal >> <Matthias.vanZaal@student.uva.nl> wrote: >> > Dear Statalist users, >> > >> > For my research I have determined the value of a variable in 12 >> > scenarios. >> > >> > "gen x_1= "input function and values" if scenario1==1" >> > >> > Each scenario's values differ in some aspect. >> > >> > I have now 12 variables, x_1 to x_12, each with n=+/- 500. >> > >> > For the next step I would like to create a new variable which >> > incorporates x_1 - x-12. >> > The variable would be something like "x_total= x_1+x_2+....+x_12", >> > with n=+/-6000. >> > >> > I tried to simply add them with the use of the generate command but >> > this did not work. I also tried to use egen with the sum >> command, but >> > this also did not work. >> > >> > What would be the correct way to create "x_total" in STATA? >> > >> > Many thanks! >> > >> > Mathijs >> > * >> > * For searches and help try: >> > * http://www.stata.com/help.cgi?search >> > * http://www.stata.com/support/statalist/faq >> > * http://www.ats.ucla.edu/stat/stata/ >> > >> >> >> >> -- >> Best, >> Mitch >> >> >> Arnelyn Abdon >> +639178034402 >> http://statadaily.wordpress.com >> http://www.facebook.com/pages/Stata-Daily/116477895082525 >> >> * >> * For searches and help try: >> * http://www.stata.com/help.cgi?search >> * http://www.stata.com/support/statalist/faq >> * http://www.ats.ucla.edu/stat/stata/ >> > > * > * For searches and help try: > * http://www.stata.com/help.cgi?search > * http://www.stata.com/support/statalist/faq > * http://www.ats.ucla.edu/stat/stata/ > -- Best, Mitch Arnelyn Abdon +639178034402 http://statadaily.wordpress.com http://www.facebook.com/pages/Stata-Daily/116477895082525 * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**References**:**st: Creating a variable from several "subvariables"***From:*"M.P.J. van Zaal" <Matthias.vanZaal@student.uva.nl>

**Re: st: Creating a variable from several "subvariables"***From:*Mitch Abdon <mitchaabdon@gmail.com>

**Re: st: Creating a variable from several "subvariables"***From:*"M.P.J. van Zaal" <Matthias.vanZaal@student.uva.nl>

- Prev by Date:
**Re: st: Creating a variable from several "subvariables"** - Next by Date:
**st: Test Joint Hypothesis of several Inequalities?** - Previous by thread:
**Re: st: Creating a variable from several "subvariables"** - Next by thread:
**st: Test Joint Hypothesis of several Inequalities?** - Index(es):