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]

RE: st: pre and post event coding


From   "Khieu, Hinh" <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   RE: st: pre and post event coding
Date   Thu, 12 Dec 2013 21:28:48 +0000

Dear Fernando, Nick, and other statalist members,

Thanks for your responses. I am pasting 40 observations below. I need a column for lag of cashta and a column of cashta one year after around downgrade. I also need 2 more columns of cashta before and after upgrade. A total of 4 columns. Could you just help me with one year lead and one year lag? I will figure out more years of lags and leads. For example, the value of second row of cashta is 0.0534525 and should be the in the lag cashta column for upgrades since it is the cash balance one year before upgrade =1 for firm gvkey (an ID in the database) 002812. Similarly, the value of the 4th row of cashta is 0.011070578 and should be in the lead cashta column for upgrades since it is one year after upgrade=1 for the same firm. The two lead and lag cashta just created should be in the same row or something so that I will create a third column for myself which is lead minus lag. I hope this is clearer and greatly appreciate any help with stata coding.

Thanks,
Hinh

GVKEY	FYEAR	cashta	upgrade	downgrade
002812	1987	0.033511614	0	0
002812	1988	0.0534525	0	0
002812	1989	0.019296537	1	0
002812	1990	0.011070578	0	0
002812	1991	0.014896329	0	0
002812	1992	0.018504308	1	0
002812	1993	0.011067856	0	0
002812	1994	0.012099207	0	0
002812	1995	0.029543541	0	0
002812	1996	0.013809676	0	0
002812	1997	0.012663689	0	0
002812	1998	0.012127395	0	0
002812	1999	0.013981739	0	0
002812	2000	0.01000064	0	0
002812	2001	0.131549467	0	0
002812	2002	0.213038699	0	0
002812	2003	0.008395931	0	1
002812	2004	0.01828809	0	0
008596	1996	0.069620253	0	0
008596	1997	0.060511541	0	0
008596	1998	0.050087362	0	0
010884	1987	0.158100174	0	0
010884	1988	0.134588069	1	0
010884	1989	0.179119977	0	0
010884	1990	0.160353232	0	0
010884	1991	0.264202242	0	0
010884	1992	0.143434548	1	0
010884	1993	0.055176807	0	0
010884	1994	0.061631187	0	1
010884	1995	0.10345515	0	0
010884	1996	0.115754212	0	1
010884	1997	0.052340656	0	0
010884	1998	0.035432956	0	0
010884	1999	0.037695768	0	0
010884	2000	0.040104436	0	0
030443	1994	0.03267254	0	0
030443	1995	0.016850206	0	1
030443	1996	0.036283762	0	1
030443	1997	0.107138038	0	0
030443	1998	0.03172147	1	0
030443	1999	0.025653675	0	0
030443	2000	0.008677145	0	0
030443	2001	0.010861392	0	0
030443	2002	0.007522965	0	0
030443	2003	0.034200644	1	0

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Fernando Furquim
Sent: Thursday, December 12, 2013 10:27 AM
To: [email protected]
Subject: Re: st: pre and post event coding

Hihn,

Could you share some code or data? Remember to -xtset- your data (so that Stata treats it as panel). Then you could use the lag and lead operators (L4 and F4 to lag/lead 4 time periods, for example). Those will lag and lead appropriately accounting for the use of panel data as long as you -xtset- first.

Assuming you have a regular old panel dataset, this should be pretty simple, but if your dataset is mixing time periods or something it'd be trickier.

Good luck!

Fernando

On Wed, Dec 11, 2013 at 10:06 PM, Khieu, Hinh <[email protected]> wrote:
> Dear Statalist members,
>
> I have a panel data of firm years. The events are credit ratings downgrades and upgrades. I want to identify the cash holdings one year before downgrade (or upgrade) and one year after downgrades (or upgrades). One objective is to construct cash holdings after minus cash holdings before the event. Another objective is to calculate cash holdings volatility 4 years before and cash holdings volatility 4 years after an upgrade or downgrade.
>
> I know how to do that in SAS, but do not know how to code it in Stata. I try the [_n-1] and [_n+1] for cash holdings, but it is not necessarily correct because the code does not wrap around an event. Here my downgrades column has 1's for downgrades and 0's otherwise. My upgrades column has 1's for upgrades and 0's otherwise.
>
> I'd appreciate any amount of help.
>
> Thanks,
> Hinh
>
> *
> *   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/

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

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