Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: counting across individuals within groups


From   Buzz Burhans <[email protected]>
To   [email protected]
Subject   st: counting across individuals within groups
Date   Thu, 30 Jan 2003 11:04:53 -0500

I would appreciate help with creating the following value, I can't seem to
get it right:

I have data with 4 vars in each record as follows:

1. farmID 	is an ID variable for farm
2. cowID 	is an ID variable for cow (within farmID)
3  enterPen 	is the date on which a cow enters Pen
4  exitPen	is the date on which the cow exits Pen

There are multiple cows within each farm, and their enterPen and exitPen
dates vary individually.

What I need is a variable that contains the count of cows within the same
farmID which have entered, but not yet exited the Pen on the date an
individual cow exits the Pen,

i.e.a count of  "other cows" within the same farmID whose enterPen date is
< exitPen date for each individual cow (within the same farmID) and whose
exitPen date (the "other cows" ) is > the exitPen date for the individual
cow ...

I can't seem to get the ifs to work correctly across different records,
probably because I'm not very good at looping.

thanks

Buzz Burhans
Department of Animal Science
Cornell University

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index