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: Assign fiscal year-end values to a specific event in time


From   miriam geringer <[email protected]>
To   [email protected]
Subject   Re: st: Assign fiscal year-end values to a specific event in time
Date   Sun, 26 Jan 2014 12:57:21 +0100

The exact is "long" and the year variable "double". In general, I have
lots of date variables. I generated monthly and yearly Stata date
variables (mofd, yofd).

I thought about doing this:

For problem 1:
bysort CompanyIdentifier (mofd(date)): replace Price = Price[_n-1] if
missing(Price)

For problem 2:
gen neg_mofd(date) = -mofd(date)
bysort CompanyIdentifier (neg_mofd(date)): replace Price = Price[_n-1]
if missing(Price)

Not sure if this is safe though, because of the fiscal years and
because of the missing values.

Thanks

2014-01-26 Nick Cox <[email protected]>:
> How can you tell Stata in terms of these data when fiscal years end?
>
> What kind of variable is -Date- (numeric or string)? Are you using
> Stata dates (see -help dates and times-)?
>
> There is much discussion of technique in
> http://www.stata-journal.com/article.html?article=dm0055
>
> Nick
> [email protected]
>
>
> On 25 January 2014 19:19, miriam geringer <[email protected]> wrote:
>
>> I have the following two datasets:
>>
>> 1)
>>
>> Company   Date      Year     Price      Event
>> A                 31Okt    1988
>> A                 29Nov    1988    10
>> A                 31Dez    1988
>> A                 31Jan     1989
>> A                 14Feb     1989                EventX
>> A                 28Feb     1989
>> A                 31Mar     1989
>> B
>> B
>> ....
>>
>> Basically, there is some event going on in 1989. This event can happen
>> in every month, on every day. I want to assign a specific value from
>> the previous fiscal-year to the event in 1989. To be more precise, I
>> want to assign the fiscal year-end price from fiscal year 1988 to the
>> event which happens - in our example - on 14Feb 1989. In the end, I
>> only need to know in what year the event happened and the
>> corresponding price from the previous fiscal year-end. Sometimes,
>> there is no price available in the previous fiscal year, then it
>> should be just marked as missing value.
>>
>> ---- Fiscal Year-End 1988 ------- Event -------- Fiscal Year-End 1889
>>>>>>> Assign Fiscal Year-End 1988 to Event
>>
>> The fiscal year can end in every month and it is possible that, for
>> example, the fiscal year ends on 31Jan 1989 and the event occurs on
>> 14Feb 1989. Then the 31Jan 1989 value shall be assigned.
>>
>> It should be something like:
>> If Stata finds an EventX in fiscal year 1989 of Company A, go to
>> fiscal year 1988 and take the 1988 fiscal year-end price of Company A
>> and assign it to the EventX in 1989.
>>
>> 2) The second dataset is identical. However, this time I want to
>> assign the first available fiscal year-end value.
>>
>> Company   Date      Year     Price      Event
>> A                 31Okt    1988
>> A                 29Nov    1988
>> A                 31Dez    1988
>> A                 31Jan     1989
>> A                 14Feb     1989               EventY
>> A                 28Feb     1989
>> A                 31Mar     1989    10
>> B
>> B
>> ....
>>
>> In this example, let's assume the year ends on 31Mar 1989 and on that
>> date, the price is 10 (the fiscal year-end price). I want to assign
>> this price to the row with the EventY and 14Feb. The same as in
>> dataset 1, just the other way around.
>>
>> It should be something like:
>> If Stata finds an EventY in year 1989 of Company A, take the first
>> available fiscal year-end value (first one available after the event
>> occured). The event can occur in February and the fiscal year can
>> could end shortly after. Just take the next available value, no matter
>> whether there is a calendar year shift in between or not.
> *
> *   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/
*
*   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