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: replacing rating information conditional on year
From
Nick Cox <[email protected]>
To
"[email protected]" <[email protected]>
Subject
Re: st: replacing rating information conditional on year
Date
Tue, 14 Jan 2014 14:58:44 +0000
This is an FAQ. See
FAQ . . . . . . . . . . . . . . . . . . . . . . . Replacing missing values
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . N. J. Cox
2/03 How can I replace missing values with previous or
following nonmissing values?
http://www.stata.com/support/faqs/data/missing.html
Perhaps you are aware of this FAQ or of similar advice. Either way, we
can't possibly comment on your "not very successful" code if you don't
tell us what it was.
Nick
[email protected]
On 14 January 2014 13:17, Christophe J. GODLEWSKI <[email protected]> wrote:
> 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)
*
* 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/