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: st: Calculating row average with egen rmean
From
"Clifton Chow" <[email protected]>
To
[email protected]
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/