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 at the end of May, and its replacement, statalist.org is already up and running.


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

st: st: Calculating row average with egen rmean


From   "Clifton Chow" <clifton_chow@post.harvard.edu>
To   statalist@hsphsun2.harvard.edu
Subject   st: st: Calculating row average with egen rmean
Date   Sat, 02 Apr 2011 16:57:23 -0500

I am trying to calculate an average hours worked across 48 months for each observation using egen rmean(hours1....hours48).  I discovered that while this works as long as a person has a positive hours across 2 or more months, for someone with positive hours on ONLY 1 month, the result for the average hours variable for that observation is a 0.  

I thought egen rmean counts only columns with data and ignores columns with missing or 0 values so that if obs 2 exhibits the data pattern below,

obs     month1 month2  month3   month4........month48  average48
1           20          .           14.75     .......(missing or 0)..       17.37
2             .        .              32         ........(missing or 0)..       32

the average48 for that person reflects the single month for which there is positive hours worked.

Is there away to correct this situation so that egen rmean would divide an observation with only one month of data by 1 ?   

Thanks
*
*   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/


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