Bookmark and Share

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: combining consecutive similar observations in time series datasets


From   Adeel Yousaf <[email protected]>
To   [email protected]
Subject   st: combining consecutive similar observations in time series datasets
Date   Mon, 18 Mar 2013 14:51:59 +0800

Hi,
how can I combine multiple rows of an activity to one row and generate
its start and end time, in panel dataset, if the activity occurs
adjacently. For example, in the first table 1 the activity code "11"
has 3 rows from 4:00 am to 5:30am, I need to get its compact form
shown in second table  :-

actual dataset:-
id      start   end     coded
100003  4:00    4:30    11
100003  4:30    5:00    11
100003  5:00    5:30    11
100003  5:30    5:45    13
100003  5:45    6:00    14
100003  6:00    6:30    14
100003  6:30    7:00    14
100003  7:00    7:15    15
100003  7:15    7:30    16
100003  7:30    8:00    16
100003  8:00    8:15    16
100003  8:15    8:30    17
100003  8:30    8:45    15
100003  8:45    9:00    15
100003  9:00    9:30    15
100003  9:30    10:00   15

what i need is:-
id      start   end     coded
100003  4:00    5:30    11
100003  5:30    5:45    13
100003  5:45    7:00    14
*
*   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index