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: Re: AW: egen rowmeaan
From
Dirk Enzmann <[email protected]>
To
[email protected]
Subject
st: Re: AW: egen rowmeaan
Date
Thu, 05 Aug 2010 14:46:30 +0200
Answering Martin Weiss
http://www.hsph.harvard.edu/cgi-bin/lwgate/STATALIST/archives/statalist.1008/date/article-118.html
I wrote
http://www.hsph.harvard.edu/cgi-bin/lwgate/STATALIST/archives/statalist.1008/date/article-229.html
Sorry, I forgot the essential point to capture the error of -which-:
* ------------------------------------------
cap which scores
if _rc ssc install scores
clear*
set obs 1000
foreach var of newlist var1-var10{
gen `var'= 10*uniform()
replace `var'= cond(runiform()>.645,.,`var')
}
* Version 1:
egen float rownonmissings = rownonmiss(var*)
egen float rowmean = rowmean(var*) if inrange(rownonmissings,7,.)
drop rownonmissings
* Version 2:
scores rowmean2 = mean(var*), nv(7)
* Check:
sum rowmean rowmean2
* ------------------------------------------
========================================
Dr. Dirk Enzmann
Institute of Criminal Sciences
Dept. of Criminology
Rothenbaumchaussee 33
D-20148 Hamburg
Germany
phone: +49-(0)40-42838.7498 (office)
+49-(0)40-42838.4591 (Mrs Billon)
fax: +49-(0)40-42838.2344
email: [email protected]
http://www2.jura.uni-hamburg.de/instkrim/kriminologie/Mitarbeiter/Enzmann/Enzmann.html
========================================
*
* 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/