Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

st: row means for at least 10 observations greater than 0


From   Nicholas Winters <nicholas.winters@mail.mcgill.ca>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   st: row means for at least 10 observations greater than 0
Date   Tue, 25 Feb 2014 15:30:00 +0000

I need to take an average of several variables in a row, but I want to average of the row only if there are at least 10 variables without 0 as their observation. The data looks like this:

PersonID  1990 1991 1992 1993 1994 1995 etc...
1               0       0       3      3      5       6
2               1       1       5      3      0       7
3               1       1       2      1      4       3 
4               0       0       0      0      5       5

does anyone have an idea how to do this? I've tried egen and rowmean() but I am not sure how to code for if a row has more at least 10 observations > 0

Thanks,
Nick
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index