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: Duration data- count number of spells with ref to current spell
From
Sriram Narayanamoorthy <[email protected]>
To
[email protected]
Subject
st: Duration data- count number of spells with ref to current spell
Date
Mon, 26 Aug 2013 12:51:50 -0700
Hello everyone,
This question is on data generation when working with a
discrete-duration datasets. The dataset I have includes all the
activities undertaken by individuals in a 24 hour period. The day is
divided into 48 half-hour intervals. The start interval of a spell is
denoted by a variable called eventStart. The activity type is denoted
by the variable eventType.
The task of counting the number of activities of a particular type
undertaken in a day by the person is quite straightforward using egen.
However, I want to generate a variable as the number of activities of
a particular type undertaken by the individual before/after the
current activity. How do I add the "Before" and "After" dimension to
my variable? To be sure, I want to compare the eventStart of my
current record with all other records for that person and count the
number of records of a particular eventType only if eventStart is less
than (for Before) or greater than (for After) the current start
period.
Any thoughts? Is there a mata approach to this? Thanks much for the inputs!
Thanks,
-Sriram
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/