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: RE: panel data cross referencing bewtween variables in different time


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: RE: panel data cross referencing bewtween variables in different time
Date   Sat, 6 Mar 2010 19:31:34 +0100

<>

*************
clear*

inp int(ID Year) byte(X1 X2 X3)
111 1990  89 	21	0
111	1991	29	53	0
111	1992	87	76	1
111	1993	87	98	1
111	1994	45	88	0
222	1990	98	88	0
222	1991	98	44	0
222	1992	45	71	0
999	1990	76	98	0
999	1991	54	43	0
999	1992	65	32	0
999	1993	65	87	1
999	1994	76	32	0
end

list, noo

bys ID: egen maxperid=max(X3==1)
by ID: egen totalX1=total(X1*maxperid)
l, noo sepby(ID)
*************


HTH
Martin

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of MoZo
Sent: Samstag, 6. März 2010 19:25
To: [email protected]
Subject: st: panel data cross referencing bewtween variables in different
time 

I have a panel dataset which was set up as follow:

ID	Year	X1	X2	X3
111   1990  89 	21	0
111	1991	29	53	0
111	1992	87	76	1
111	1993	87	98	1
111	1994	45	88	0
222	1990	98	88	0
222	1991	98	44	0
222	1992	45	71	0
.
.
.
.
999	1990	76	98	0
999	1991	54	43	0
999	1992	65	32	0
999	1993	65	87	1
999	1994	76	32	0

I want to do simple calculation referencing to one variable X3. For example,
sum X1 for ID (panel) if the panel's X3=1 in ANY year. I can't find a
command I can make reference to a variable that may occur any time. For
example, in this data sample, I want to all X1 for all ID whose X3 is 1 in
ANY year. 
Thank you in advance. 

Mike 

*
*   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/


*
*   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/


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