HI!
I think I need different codes for 1)holding period return and 2)monthly, yearly return, or similar.
holding period return is tricky because I need to use days from a certain date to another certain date. In other words, I cannot simply make code someday+1's price and divide a previous day by the next day.
For exmaple, from July 12th, 2019, one-day HPR needs the next business day, July 15th, 2019. So... To calculate one-day holding period return, I may need a new code other than day+1. I guess there should the code navigating adding or subtracting days by the order of rows on certain variables. (For example, if the interval is +- 1 business days, that would be July 11st and July 15th, 2019 as my CRSP daily data has the price row following business days) So far, I have looked for the code having date interval specified by the order of rows of interest. Please share your knowledge... Maybe my ability to search for the answer is so poor...
Another question is also related to the above question. If I need to know a month return from June 7th, 2019 to July 7th, 2019, I need to have stock prices on both dates. Well... 2019/07/07 is Sunday so I need next day, Monday. In that case, I need another code that automatically finds the next available date on my dataset. I think this is quite an advanced SAS programming.
Maybe the gist of those coding is how to skillfully use the order of rows and I even wonder whether this is possible.
There is almost no way to express my thankfulness to you have helped me other than writing here. However, I would like to thank you again for your helpful replies very much!!!!
Jerry
This link can answer most of my questions.
But still... I wonder how can I get a monthly return from a specific date.
It would be better to elaborate more.
There is data having the date stocks purchased. (stock ID, date_purchased)
There is another data having the daily price of stocks. (stock ID, date, price)
I want to calculate holding period returns using date and price in the second data. Both date_purchased and date are based on business days so ordinary +@ days does not work... 😞
This link can answer most of my questions.
But still... I wonder how can I get a monthly return from a specific date.
Please supply example data in usable form (data step with datalines), so we have something to play around with, and what you expect out of it.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.