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 |
Stas Kolenikov <skolenik@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: programming question for instrument scoring with weights |

Date |
Thu, 9 Jun 2011 11:14:18 -0500 |

Right. Did not RTFM carefully enough. Marguerite may have to follow the -egen = rowtotal()- with something like egen miss_items = rowmiss( [all contributing items] ) replace total_score = . if miss_items if the missing values in the items are to produce missing values in the total score. On Thu, Jun 9, 2011 at 11:06 AM, Austin Nichols <austinnichols@gmail.com> wrote: > Stas-- > > Not well, though: > > . egen m=rowtotal(rep78 price), missing > > . su m rep78 price > > Variable | Obs Mean Std. Dev. Min Max > -------------+-------------------------------------------------------- > m | 74 6168.432 2949.481 3294 15909 > rep78 | 69 3.405797 .9899323 1 5 > price | 74 6165.257 2949.496 3291 15906 > > > > On Thu, Jun 9, 2011 at 12:02 PM, Stas Kolenikov <skolenik@gmail.com> wrote: >> Oops. Thanks, Austin! There's -missing- option of -egen = rowtotal()- >> controlling for the missing value issue, too. >> >> On Thu, Jun 9, 2011 at 10:48 AM, Austin Nichols <austinnichols@gmail.com> wrote: >>> Stas; Marguerite <mbaty1@son.jhmi.edu>: >>> I think the -egen- "function" below is meant to be rowtotal(), not >>> total(). But beware of missing values counting as zeros in such a >>> formulation. >>> >>> On Thu, Jun 9, 2011 at 10:52 AM, Stas Kolenikov <skolenik@gmail.com> wrote: >>> ... >>>> I am assuming that your items are coded 1 for yes, 0 for no. Or you >>>> can do this sequentially: >>>> >>>> egen int total_score = total( item1 item2 [fill in the dots] item19 ) >>>> replace total_score = total_score + 4 if item2 == 1 >>>> ... >>>> replace total_score = total_score - 3 if item3a == 1 >>>> >>>> All of these ways are cumbersome, and the more lines of code you have, >>>> the more likely it is you will have an error somewhere. The choice >>>> between different ways of coding your problem is a matter of >>>> aesthetics, and how readable the code will be to you and other users >>>> of it. > > * > * 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/ > -- Stas Kolenikov, also found at http://stas.kolenikov.name Small print: I use this email account for mailing lists only. * * 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: programming question for instrument scoring with weights***From:*"Lucea, Marguerite" <mbaty1@son.jhmi.edu>

**Re: st: programming question for instrument scoring with weights***From:*Stas Kolenikov <skolenik@gmail.com>

**Re: st: programming question for instrument scoring with weights***From:*Austin Nichols <austinnichols@gmail.com>

**Re: st: programming question for instrument scoring with weights***From:*Stas Kolenikov <skolenik@gmail.com>

**Re: st: programming question for instrument scoring with weights***From:*Austin Nichols <austinnichols@gmail.com>

- Prev by Date:
**Re: st: Problem with margins after logit on a person period data** - Next by Date:
**st: logistic regression confidenceintervals** - Previous by thread:
**Re: st: programming question for instrument scoring with weights** - Next by thread:
**st: minimum number of obs for xtmixed** - Index(es):