Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

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

From |
Steve Samuels <sjsamuels@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: egen rowtotal |

Date |
Sun, 15 Jul 2012 14:37:36 -0400 |

Another approach is to convert the 99's to missing values, which they are, before running -egen rowtotal-. This modifies the original data, but in many studies would be an acceptable, even desirable, step in data editing. **************************************** mvdecode structured-reg_num, mvdecode(99) **************************************** Steve sjsamuels@gmail.com On Jul 15, 2012, at 1:48 PM, Nick Cox wrote: I think that if you choose the -egen- turning then the road ahead is blocked, short of an enormously complicated -if- condition. But it is easy enough to work this out from first principles. gen sum = 0 qui foreach v of var structured-reg_num { replace sum = sum + `v' if inlist(`v', 1, 2, 3) } replace sum = . if sum == 0 For a more systematic discussion, see SJ-9-1 pr0046 . . . . . . . . . . . . . . . . . . . Speaking Stata: Rowwise (help rowsort, rowranks if installed) . . . . . . . . . . . N. J. Cox Q1/09 SJ 9(1):137--157 shows how to exploit functions, egen functions, and Mata for working rowwise; rowsort and rowranks are introduced Nick On Sun, Jul 15, 2012 at 6:08 PM, Nikolaos Pandis <npandis@yahoo.com> wrote: > I am using the following command to get a row total for 16 variables: > > egen sum = rowtotal(structured- reg_num ) > > the possible values per variable are 1, 2, 3 or 99 and I would like the row total by adding only the 1s, the 2s and the 3s and to excluded the 99s. * * 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: egen rowtotal***From:*Nikolaos Pandis <npandis@yahoo.com>

**Re: st: egen rowtotal***From:*Nick Cox <njcoxstata@gmail.com>

- Prev by Date:
**Re: st:graph mean with missing groups** - Next by Date:
**st: Testing model fit for gologit2** - Previous by thread:
**Re: st: egen rowtotal** - Next by thread:
**Re: st: egen rowtotal** - Index(es):