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: panel data-dropping all observations for the identifier when certain variable value is missing


From   Nick Cox <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   RE: st: panel data-dropping all observations for the identifier when certain variable value is missing
Date   Wed, 6 Jul 2011 11:08:03 +0100

Muhammad:

Sorry, but my answer is the same as before. 

1. The intent of your code was first to -keep- years greater than 2008. Once that is done your subsequent -keep- commands would have made no difference. 

2. As I say, this was the intent of your code, but as previously pointed out, your syntax was illegal. 

3. As I understand Sabrina, she wants to drop short panels, which is not addressed by your code at all, as it does not work with whole panels. 

So, I think that your suggested code is wrong in three different senses. Note that _older_ dates are _less than_ some given date. 

Should Sabrina explain that she didn't mean what she said, or otherwise that the problem has been misunderstood, then the question will need to be looked at again. 

Nick 
[email protected] 

Muhammad Anees

Thank you nick for the correction but what I guess from the problem
statement is that Sabrina just wants to drop observations where the
offdate is less than a specific date in 2008 and she wants to keep
offdate where the date should be greater than the date in 2008.

Just to remind and not challenging, she states
"For cases where the last value for the variable <offdate>, which is a
variable containing dates, is older than a date in 2008 (so date in
2007, 2006,...) then stata shall drop the firm/identifier at all, so
for every year. Then, I want stata to show me for every
firm/identifier the last entry for the variable <offdate>, which could
then either be a date in 2008, 2009 or 2010"

What I suggested should work if the date variable is in acceptable
format in Stata. Yes I accept the ignoring of missing data effect on
my suggestions if that had an effect.

Anyway I am thankful for your correcting my guess and welcome more guidance.

Anees

On Wed, Jul 6, 2011 at 12:44 PM, Nick Cox <[email protected]> wrote:

> This is quite wrong.
>
> The -keep- command has two basic syntaxes which can not be combined,
> so all code here is illegal. In any case if this syntax worked the
> effect would be to leave only -xvar- for -date-s greater than 2008,
> whereas the problem is different, to drop panels that are too short.
>
> See my earlier post for another suggestion.

> Nick
>
> On Wed, Jul 6, 2011 at 4:32 AM, Muhammad Anees <[email protected]> wrote:
>> drop xvar if date<datein2008 will drop all those observations with
>> missing datein2008 observations too as I guess. but the inverse
>> command of -keep-ing will do the job. You can use
>>
>> keep xvar if date>datein2008
>> keep xvar if date>datein2007
>> keep xvar if date>datein2006
>> etc.
>>
>>
>> Hope this works
>
>> On Wed, Jul 6, 2011 at 5:07 AM, Sabrina Helmut <[email protected]> wrote:
>
>>> I have firm-year observations for the years 2003-2010. For cases where the last value for the variable <offdate>, which is a variable containing dates, is older than a
>>> date in 2008 (so date in 2007, 2006,...) then stata shall drop the firm/identifier at all, so for
>>> every year. Then, I want stata to show me for every firm/identifier the last entry for the variable <offdate>, which could then either be a date in 2008, 2009 or 2010. Which commands could help me doing this?

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