03-05-2018 06:36 PM
it coincides with data from 12/31 it seems:
|row||date||ticker ret annual_return|
03-05-2018 06:42 PM
You might have to fix the data first then. If RET is missing, all the calculations based on RET will also be missing.
If that's what needs to be fixed, however, it's easy for SAS to remove the observation with a missing RET and base the calculations on the remaining data.
03-05-2018 06:43 PM - edited 03-05-2018 06:44 PM
okay, I will do a datstep to drop observations with missing RET then. Also, I will do some research to see if these annual_return figures are accurate.
03-05-2018 07:38 PM
The DATA step can be "fixed" if it has to deal with years that don't begin in January or that don't end in December. But it does take a decision as to whether the first year must end in December, and the last year must begin in January and use as many months as appear in the data.
03-05-2018 08:19 PM - edited 03-05-2018 08:21 PM
It will lose the years that don't end with December. It's not hard to fix the program (or else you could just add the missing December with RET=0). The other question though is what happens if the first year begins in, say, November. Should the first year then be 2 months long?
03-06-2018 11:14 AM
Hey @Astounding, thanks for helping me create the variable annual_return! Could I ask what is the source of the equation you used/what it would look like in mathematical form? It's sort of hard to see in the code. Thanks!
03-06-2018 11:23 AM
I didn't use a formula, just logic. Here's the idea. If you start with $x, and your return is Y% (Y as a decimal fraction), after one time period the value is:
$X * (1 + y)
That compounds monthly. At the end of all the time periods, to compute the total return, you have:
(Final $X - Original $X) / (Original $X)
The math gets simplified when you start with Original $X of 1 each time.
You also wanted the percents on a scale of 0 to 100, instead of 0 to 1. So multiply by 100.
03-06-2018 02:54 PM
Does an annual return of this magnitude make sense? Like an annual return of 11,819%?
row date ticker cusip ret year annual_return
03-06-2018 02:59 PM
Not at all. What were the monthly values that generated this annual return?
Also remember, these values get multiplied by 100 at the end. So make sure that the result is what you are posting, and not 118.19%
03-06-2018 03:59 PM
also, I don't recall there being a variable in the dataset for dollars ($) earned over the month. We are only dealing with a rate of return (%) as seen in the ret column. Is this correct?
03-06-2018 04:24 PM - edited 03-06-2018 04:28 PM
Dollars earned over the month would be starting value * RET. But since you're not interested in dollars earned, only in the rate of return, the starting value gets arbitrarily set to $1 at the beginning of each year. The final rate of return looks at the final value compared to the starting value. It computes the difference which (based on a starting value of $1) is the rate of return for the year.
Take a simple example: just 2 months in the year, each with a return of 10%. The calculations ...
At the beginning, value is $1.
After 1 month, value is $1 * (1 + 10%) = $1.1
After 2 months, value is $1.1 * (1 + 10%) = $1.21
The combined rate of return compares $1.21 to the original value of $1:
($1.21 - $1) / $1 = 21%
Being interested in the rate of return only, the original starting value does not really matter. Say it was $50 at the beginning.
After 1 month, value is $50 * (1 + 10%) = $55
After 2 months, value is $55 * (1 + 10%) = $60.50
The combined rate of return compares $60.50 to the original value of $50:
($60.50 - $50) / $50 = 21%
Now that I've spelled out these examples, I'll go back and verify that this is the way I applied the formulas.
Yes, the formulas match, with one exception. The calculations in this example yield 0.21 as the annualized rate of return. The problem description looked like you were asking for an answer of 21 instead of 0.21. So the program multiplies by 100 at the end. Multiplying by 100 can easily be removed if you would prefer.
03-06-2018 04:34 PM
Wow, thank you so much for the help and examples. Very helpful. So if this annual_return variable is accurate, which I believe you when you say it is, then say (for example) firm AA had a good year? An annual return of 11819.25%?
03-06-2018 04:41 PM - edited 03-06-2018 04:43 PM
Again, show the monthly returns that appear in the data for AA, for that year. It should be an easily calculation to verify once we're looking at the monthly returns.
One thing to verify, while you are examining the data. Did the prior year for AA have a December date included in the data?
And remember, anything is possible. Some CEOs decide to take a $1 salary for a while, and later go back to a different system.
03-06-2018 04:47 PM
I don't have time to try the calculation at the moment, but here is the AA data (there appears to only be one year for it):
Need further help from the community? Please ask a new question.