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: dividend programming question


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: dividend programming question
Date   Sun, 24 Mar 2013 09:32:16 +0000

Note that the presence of missings complicates my earlier solution, better as

egen yearfirstpaid = min(year / (dividend > 0 & dividend < .)), by(firmid)
gen wasfirst = year == yearfirstpaid

fillin firmid year
gen omitted = missing(dividend)

may be as much as you want. On the other hand, I still don't
understand the line

1996                     .10            1

Your question (and your example) are contradictory. If you want your
indicator to be 1 in years with a dividend, why do you also want it to
be 1 as above.

Nick

On Sat, Mar 23, 2013 at 7:57 PM, Nick Cox <[email protected]> wrote:

> As said, do look at the -help- for -fillin-. It will help with your gaps.

> On Sat, Mar 23, 2013 at 7:51 PM, Khieu, Hinh <[email protected]> wrote:

>> Thanks so much for your prompt help.
>>
>> Here's what I meant for question #2: Let's say I have firm A and firm B below. I want to create a binary variable called Omission. Firm B has dots, but Firm A do not have any records for div paid from 1997-2001.
>> FirmA                    Div paid       Omission
>> 1995                     .10            0
>> 1996                     .10            1
>> 2002                     .15            0
>> 2003                     .15            0
>> 2004                     .15            0
>> 2005                     .10            0
>> 2006                     .10            0
>> 2007                     .10            0
>> 2008                     .10            0
>> 2009                     .12            0
>> 2010                     .12            0
>> 2011                     .12            0
>> 2012                     .15            0
>> FirmB                 Div paid          Omission
>> 1995                     .10            0
>> 1996                     .10            0
>> 1997            .               1
>> 1998            .               1
>> 1999            .               1
>> 2000            .               1
>> 2001            .               1
>> 2002                     .15            0
>> 2003                     .15            0
>> 2004                     .15            0
>> 2005                     .10            0
>> 2006                     .10            0
>> 2007                     .10            0
>> 2008                     .10            0
>> 2009                     .12            0
>> 2010                     .12            0
>> 2011                     .12            0
>> 2012                     .15            0

Nick Cox

>> #1. Given
>>
>> firmid year dividend
>>
>> the first year when -dividend- > 0 is
>>
>> egen yearfirstpaid = min(year / (dividend > 0)), by(firmid)
>>
>> and so an indicator for first year is
>>
>> gen wasfirst = year == yearfirstpaid
>>
>> #2. Not clear to me. You seem to be saying both that you do and do not have observations for certain years. Please review Stata terminology:
>>
>> an observation is a record, case, or row (and _not_ a value)
>>
>> a value is the value of a variable
>>
>> missing values are present in the data, but missing
>>
>> If observations are not present in the data, they are (in my view) better called "omitted" or "not present".
>>
>> See -help fillin- as a first step.
>>
>> Nick
>>
>> On Sat, Mar 23, 2013 at 6:45 PM, Khieu, Hinh <[email protected]> wrote:
>>
>>> I have an unbalanced time series data: firm ID, year, and annual
>>> dividend amount. I want to create 2 binary variables
>>>
>>>
>>>
>>> 1/  indicating when firm A pays dividends for the first time. Firms
>>> may enter the dataset and pay div for the first time right at the
>>> first data entry (example: firm A first appears in data 1990 and pays
>>> div in 1990, and the variable should be 1 for 1990 and zero for other
>>> years. Firms may enter the data set and do not pay any div until 5
>>> years later (example: first appear in data 1990 and pay div in 1995,
>>> and dummy should be 1 for 1995 and zero for other years.) What makes
>>> it complicated is that firms may skip paying div for some years and
>>> come back starting to pay div again. The same binary variable should
>>> be 1 if the firm does not pay div for 5 years and starts repaying div
>>> in year 6 (example: first appear in data 1990 and pay div in 1995, and
>>> dummy should be 1 for 1995 and firm does not pay any div in years 1996
>>> through 2001 and starts paying div in 2002, dummy should be zero for
>>> 1996-2001 and 1 for 2002 and zero for other years.)
>>>
>>>
>>>
>>> 2/ the second dummy captures the omission of dividends above. If firm A pays div in 1995-1996, stops paying from 1997-2001, and pays again 2002 to 2013, dummy should be zero for 1995-1996, one for 1997-2001, and zero again 2002-2013. The problem is that sometimes observations for 1997-2001 are just dots, sometimes the observations are like this (year 1997-2001 are not there):
>>>
>>> FirmA                    Div paid
>>>
>>> 1995                     .10
>>>
>>> 1996                     .10
>>>
>>> 2002                     .15
>>>
>>> 2003                     .15
>>>
>>> 2004                     .15
>>>
>>> 2005                     .10
>>>
>>> 2006                     .10
>>>
>>> 2007                     .10
>>>
>>> 2008                     .10
>>>
>>> 2009                     .12
>>>
>>> 2010                     .12
>>>
>>> 2011                     .12
>>>
>>> 2012                     .15
>>>
>>>
>>>
>>> In this case, I want the omission dummy to be 1 in year 1996.
>>

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