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: Keep variables if a value is available for a specific date


From   Tanja Berg <tanja.berg86@gmx.de>
To   statalist@hsphsun2.harvard.edu
Subject   st: Keep variables if a value is available for a specific date
Date   Sun, 13 May 2012 17:44:25 +0200

Dear Statalist-User,

I have a problem I am not able to solve so far.
My data set looks like the following:

ID		Date		Price
1		01.01.2005	100
1		02.01.2005	100,9
1		03.01.2005	100,5
1		04.01.2005	100,3
...		....			....
2		01.01.2005	100
2		02.01.2005	100,3
2		03.01.2005	a. (missing)
2		04.01.2005	100,4
...		....			....


For each ID I only want to keep the observations for the 31.03., 30.06., 30.09. and 31.12. of each year in my dataset. But if e.g. the price on the 31.03. is missing I want to keep the next possible available price.
My dataset is so large I can't look at each observation separately. So I think I will need some kind of loop that checks if the price e.g. for the 31.03. is available and then keeps the observation or if the price is not available, checks the 01.04. if there is a price available and then keeps this observation etc.

Can someone help me with this problem?

Best regards
*
*   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