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: "table" showing summary of ~100 ternary variables?

From   Phil Schumm <>
Subject   Re: st: "table" showing summary of ~100 ternary variables?
Date   Sat, 30 Oct 2010 16:21:50 -0500

On Oct 30, 2010, at 3:13 PM, Phil Schumm wrote:
Now, we'll compute the proportion correct (as a proportion of values 1-3) for each variable:

   egen correct = max((y==1)*cnt), by(Var)
   egen nonmiss = sum(inlist(y,1,2,3)*cnt), by(Var)
   bys Var (y): replace cnt = correct[1] / nonmiss[1] if y == 5

Note for the record that the third line above may be replaced with the simpler

    replace cnt = correct / nonmiss if y == 5

(the original was left over from an initial approach which I then simplified).

-- Phil

*   For searches and help try:

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