Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down at the end of May, and its replacement, **statalist.org** is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
Nick Cox <njcoxstata@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: combining consecutive similar observations in time series datasets |

Date |
Mon, 18 Mar 2013 18:02:35 +0000 |

Jeph gave very good advice, but there's a broader problem. In threads starting http://www.stata.com/statalist/archive/2013-03/msg00424.html http://www.stata.com/statalist/archive/2013-03/msg00678.html you previously asked essentially the same kind of question. The answers included references to programs you can use and articles you can read. What is going wrong? If the answers are too complicated for you, everyone is wasting their time until you learn the Stata basics to understand what to do and/or ask questions about what you don't understand. Perhaps you need to find someone at your university to talk solutions through, as asking on the list seems not to be helping. Nick On Mon, Mar 18, 2013 at 2:09 PM, Jeph Herrin <stata@spandrel.net> wrote: > You don't indicate if you need to worry about gaps. If not, then this will > work: > > bys id coded (start) : egen newstart=start[1] > bys id coded (end) : egen newend = end[_N] > bys id coded : keep if _n==1 > > Or, if you really don't have any other variables > > collapse (min) start (max) end, by(id coded) > > will work. > > > On 3/18/2013 2:51 AM, Adeel Yousaf wrote: >> 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/

**References**:**st: combining consecutive similar observations in time series datasets***From:*Adeel Yousaf <townplanneradeel@gmail.com>

**Re: st: combining consecutive similar observations in time series datasets***From:*Jeph Herrin <stata@spandrel.net>

- Prev by Date:
**Re: st: Clustering help** - Next by Date:
**Re: st: generating synthetic data with a negatively skewed distribution?** - Previous by thread:
**Re: st: combining consecutive similar observations in time series datasets** - Next by thread:
**st: Clustering help** - Index(es):