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

From |
"Martin Weiss" <martin.weiss1@gmx.de> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
AW: st: AW: AW: sum of many variables |

Date |
Tue, 27 Oct 2009 15:09:23 +0100 |

<> " As always you need to check that it picks up exactly what you want and no more." Andrea may like -unab- for the purpose of checking for the right stuff inside her -varlist-: **** clear* set obs 1 gen myvar1=1 gen myvar2=1 gen myvarr=4 gen mvar=9 unab vars: myvar* di "`vars'" **** HTH Martin -----Ursprüngliche Nachricht----- Von: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Nick Cox Gesendet: Dienstag, 27. Oktober 2009 15:00 An: statalist@hsphsun2.harvard.edu Betreff: RE: st: AW: AW: sum of many variables As the order of variables is quite immaterial to their sum, another possibility is to use a wildcard such as -x*-. As always you need to check that it picks up exactly what you want and no more. Nick n.j.cox@durham.ac.uk Andrea Rispoli Thank you very much! On Mon, Oct 26, 2009 at 7:54 PM, Martin Weiss <martin.weiss1@gmx.de> > > Note, however, that there is a hazard involved when specifying a -varlist- > that encompasses all variables between "x1" and "xn" via the dash notation: > The number of variables between them changes with the -sort- order, as seen > after -describe- (see [U], page 101, example 14). So next time you run this > code, the result could be different. Issuing an explicit -sort- or -order- > could save you trouble. > > Also note that the -sum()- function would give you a running sum, and > accepts only a -varname-, not a -varlist-... > Martin Weiss > ************* > egen x=rowtotal(x1-xn) > ************* Andrea Rispoli > I would like to use the sum command, i.e. > > egen x= sum (x1, x2...xn) > > however since my n is a large number I would like to indicate that I > want the sum from x1 to xn without specifying all variables. * * 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/

**References**:**st: sum of many variables***From:*Andrea Rispoli <andrea.rspl@gmail.com>

**Re: st: AW: AW: sum of many variables***From:*Andrea Rispoli <andrea.rspl@gmail.com>

**RE: st: AW: AW: sum of many variables***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

- Prev by Date:
**Re: st: Inappropriate lines joining up between individuals in twoway line graph** - Next by Date:
**st: AW: RE: levpet for service sector firms** - Previous by thread:
**RE: st: AW: AW: sum of many variables** - Next by thread:
**st: New package -listtab- on SSC** - Index(es):

© Copyright 1996–2017 StataCorp LLC | Terms of use | Privacy | Contact us | What's new | Site index |