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]
Re: st: Duration data- count number of spells with ref to current spell
From
Sriram Narayanamoorthy <[email protected]>
To
[email protected]
Subject
Re: st: Duration data- count number of spells with ref to current spell
Date
Mon, 26 Aug 2013 14:01:22 -0700
Hi Nick,
Thanks for the response. Though, I am not quite sure I understand the
solution. Is the variable "activity" in your toy dataset is the
eventType I referred to in my question or is it something else. I
think your approach would give me the net time spend in other
activities before current activity (or time remaining to spend). What
I want to do is count the number of activity of a particular type.
I have provided an example below:
person eventStart eventType
1 10 work
1 14 lunch
1 15 work
1 16 work
1 33 shopping
1 34 shopping
The dataset is sorted in person and eventStart. Say, I want to count
the number of "work" events before and after the current event - based
on the eventStart variable. This would be my output. For, example for
the lunch tour, I have 1 work tours before time period 14 and 2 work
tours after time period 14.
person eventStart eventType numWorkBefore
numWorkAfter
1 10 work 0
2
1 14 lunch 1
2
1 15 work 1
1
1 16 work 2
0
1 33 shopping 3
0
1 34 shopping 3
0
Please let me know if I am misunderstanding your solution.
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/