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: data row transformation for irregular consecutive days
From
Kaspar Dardas <[email protected]>
To
[email protected]
Subject
st: data row transformation for irregular consecutive days
Date
Mon, 22 Feb 2010 16:33:53 +0100
Hi together,
I have a list consisting of two rows: symbols (here only AAL is shown)
and dates. Some of the dates are consecutive. There is no general rule
as to when days are consecutive.
There are sometimes 2 consecutive days in the same month, sometimes
only three in the entire year and sometimes only one day in a whole
year. I would like to transform my data
in the way shown below. Thus, I need to switch from one row for days
to two rows for days. For a single day observation both rows will have
the same date. >For a consecutive days observation the first row
should show the
start date and the second row should show the end day of the
consecutive observation.
Is there a fast way in Stata 11 to do this data transformation?
What I have:
symbol days
AAL 04-10-2004
AAL 10-01-2005
AAL 11-01-2005
AAL 12-01-2005
AAL 01-04-2005
AAL 04-04-2005
AAL 06-06-2005
AAL 07-06-2005
AAL 08-06-2005
What I need:
AAL 04-10-2004 04-10-2004
AAL 10-01-2005 12-01-2005
AAL 01-04-2005 01-04-2005
AAL 04-04-2005 04-04-2005
AAL 06-06-2005 08-06-2005
Many thanks,
Kaspar
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/