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: _N in by-groups
From
Matthew White <[email protected]>
To
[email protected]
Subject
st: _N in by-groups
Date
Fri, 19 Aug 2011 03:21:01 +0300
If a Stata command has by-groups, it seems like _N is interpreted
sometimes as the number of observations in the by-group and sometimes
as the number of observations in the data set. I'm writing a byable
program in which I want _N to be interpreted the former way, but I'm
having trouble; the default interpretation seems to be that _N is the
number of observations in the data set. I could do this:
program example, byable(recall)
marksample touse
preserve
qui keep if `touse'
[code...]
restore
end
But the preserve/keep would be slow with large data sets, right? Are
there better ways to do this?
Thank you,
Matt
--
Matthew White
Evaluation Coordinator
Urban Micro-Insurance Project
Innovations for Poverty Action
+254 (0)701 025 276
[email protected]
*
* 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/