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: replacing rating information conditional on year


From   "Christophe J. GODLEWSKI" <[email protected]>
To   <[email protected]>
Subject   st: replacing rating information conditional on year
Date   Tue, 14 Jan 2014 14:17:50 +0100

Dear all

I couldn't come up with a smarter title of my issue so...

I have the following dataset (extract) :

year	issuer_parent_eqy_ticker	rat
2006	000157 CH Equity	
2010	000157 CH Equity	
2012	000157 CH Equity	BB+
2007	012330 KS Equity	BBB-
2008	012330 KS Equity	
2010	012330 KS Equity	BBB
2012	012330 KS Equity	BBB+
2000	13 HK Equity	A
2001	13 HK Equity	
2003	13 HK Equity	
2003	13 HK Equity	A-
2005	13 HK Equity	
2006	13 HK Equity	
2007	13 HK Equity	
2008	13 HK Equity	
2009	13 HK Equity	
2010	13 HK Equity	A-

And I want this to happen:

year	issuer_parent_eqy_ticker	rat
2006	000157 CH Equity	
2010	000157 CH Equity	
2012	000157 CH Equity	BB+
2007	012330 KS Equity	BBB-
2008	012330 KS Equity	BBB-
2010	012330 KS Equity	BBB
2012	012330 KS Equity	BBB+
2000	13 HK Equity	A
2001	13 HK Equity	A
2003	13 HK Equity	A-
2003	13 HK Equity	A-
2005	13 HK Equity	A-
2006	13 HK Equity	A-
2007	13 HK Equity	A-
2008	13 HK Equity	A-
2009	13 HK Equity	A-
2010	13 HK Equity	A-

Basically for each identifier of a firm (ticker) I want to replace its
rating (rat) by the previous one until a new rating occurs
For this firm 000157 CH Equity the rating occurs in 2012 so nothing should
be put in rat before
While for firm 012330 KS Equity the rating from 2007 should also apply to
2008, then in 2009 a new rating occurs so no replacement is needed
Finally for firm 13 HK Equity it gets more tricky because in 2001 I need the
replacement of the rating using the one from 2000 but in 2003 I need the
proper rating from 2003 to be duplicated as well in the line where it is
missing, then again fill the blanks with the 2003 rating until a new rating
occurs and so on
I tried using replace and lags using [_n-1] but im not very successful
(being a rather newbie to stata btw)
Thank you very much in advance for your time, advice and help
Best regards
CG
*
*   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