Bookmark and Share

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, is already up and running.

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

Re: st: programming question for instrument scoring with weights

From   Austin Nichols <>
Subject   Re: st: programming question for instrument scoring with weights
Date   Thu, 9 Jun 2011 11:48:22 -0400

Stas; Marguerite <>:
I think the -egen- "function" below is meant to be rowtotal(), not
total().  But beware of missing values counting as zeros in such a

On Thu, Jun 9, 2011 at 10:52 AM, Stas Kolenikov <> 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:

© Copyright 1996–2016 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index