Bookmark and Share

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]

st: RE: Panel data - Finding a match for an observation in one variable, from among some values of a different variable, in a previous time period


From   Adel Enpaya <Adel.Enpaya@uws.ac.uk>
To   "'statalist@hsphsun2.harvard.edu'" <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Panel data - Finding a match for an observation in one variable, from among some values of a different variable, in a previous time period
Date   Tue, 27 Nov 2012 11:17:49 +0000

Dear 
Can anyone show me how to run Tobit regression in stat 12
Thanks 
Adel

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Rahul Ahluwalia
Sent: 27 November 2012 10:46
To: statalist@hsphsun2.harvard.edu
Subject: st: Panel data - Finding a match for an observation in one variable, from among some values of a different variable, in a previous time period

Dear Statalist
First of all, thank you. I've found many of the solutions posted here to be very helpful. I'll try and explain my current problem as best I can. I have some very inefficient and inelegant code that gets me what I need, but I would appreciate knowing the 'proper' way of doing this.

I have the following variables : year, id, comp_value, match_value, batch, test_flag. The data is in an unbalanced panel using year and id. test_flag indicates when an id enters the panel. I need to do the following - whenever test_flag == 1, I need to check that observation's match_value with the comp_value of all observations in the previous year that belong to the same batch and make note of the id. e.g 


year id comp_value  match_value batch test_flag   match_id
1999  1   505	             76     9       0          .
1999  2   500	             89     8       0		.
1999  3   505	             98     8       0		.
2000  1   55	             10     9       0		.
2000  2   500	             40     9       0		.
2000  4   500	             505    8       1          .
2001  5   0			55	8	  1		.

The code I need would compare the match_value of id 4, year 2000, i.e 505, check it against the comp_value of all observations from year 1999 and the same batch(8) and change match_id to 3. The code would also check year 2001 and id 5 but would not cause any change in match_id. What would be really great is if another variable, say, match_count would tell me if there are multiple matches.

Regards
Rahul

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


Please consider the environment and think before you print

***************************************************************************************************************

University of the West of Scotland aims to have a transformational influence on the economic, social and cultural development of the West of Scotland and beyond by providing relevant, high quality, inclusive higher education and innovative and useful research. 

Visit www.uws.ac.uk for more details

University of the West of Scotland is a registered Scottish charity. Charity number SC002520.

***************************************************************************************************************

Legal disclaimer
--------------------------

The information transmitted is the property of the University of the West of Scotland and is intended only for the person or entity 
to which it is addressed and may contain confidential and/or privileged material.  Statements and opinions expressed in this e-mail may not represent those of the company.  Any review, retransmission, dissemination and other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited.
If you received this in error, please contact the sender immediately and delete the material from any computer. 

--------------------------

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index