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 setup
From
M Martin <[email protected]>
To
[email protected]
Subject
st: Duration setup
Date
Thu, 24 Nov 2011 17:45:59 +0100
Dear Statalistusers,
I am trying to work out a solution to how I can arange my data in a
way that can be used in duration analysis.
Let me show you a example of the data:
newid year var1var2 var3
1185039 2007 4254 39673 1565
1185039 2008 9456 102467 2076
1185039 2009 2275 24896 954
1651511 2001 15246 123543 69
1651511 2002 4014 30273 43
1651511 2003 5670 44057 27
1651511 2004 5400 42207 19
1651511 2005 1386 10543 6
1651511 2006 missing
1651511 2007 missing
1651511 2008 missing
1651511 2009 7056 46650 5
1651514 2001 640 2756 4
1651514 2002 26024 120328 15
1651514 2003 10608 66060 32
1651514 2004 20836 122172 29
1651514 2005 49117 254606 92
As you can see there is some missing values (for var1-var3) for some
of the years for the ID 1651511. For the ID 1651511 I want to have one
observation for the years 2001-2005 with the sums and means for
var1-var3 and a count of the number of years, Then I want one obs with
the same info for 2009. For the ID 1185039 I want one obs for
2007-2009 with the same info as for the previous mentioned ID.
Can anyone point me in the right direction of how to write a program
that does this for many different ID's? I tried searching the
FAQ/archives, but couldn't find any match.
Thanks!
*
* 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/