[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: summing variables that have similar names
From
Richard Goldstein <[email protected]>
To
[email protected]
Subject
Re: st: summing variables that have similar names
Date
Tue, 14 Jul 2009 11:38:10 -0400
use -egen- rather than -gen-
you do not need a loop
Rich
MAY BAYDOUN wrote:
Dear Statalisters,
I was wondering if someone can help me figure out this:
I have several variables that are mutually exclusive. In other words, if one has a value, the others are missing. I want to sum them into a single variable so that all observations have a value. They start with the same few letters, say xyz but have different letters or numbers thereafter.
I tried: gen newvar=sum(xyz*) but it didn't work out. Is there another way to do this? I am guessing a loop?
Thanks a lot for any help you can provide,
Best,
May
May Baydoun, PhD in Epidemiology (UNC-Chapel Hill) Staff Scientist, National Institute on Aging, NIH/IRP, Biomedical Research Center, Baltimore, MD
*
* 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/
© Copyright 1996–2024 StataCorp LLC | Terms of use | Privacy | Contact us | What's new | Site index |