09-23-2017 03:18 PM
I am still somewhat new to SAS (last year) and haven't used it in a while. Can someone please help with using either Proc sql or other data/Proc steps that come to mind to get me started in answering the following:
1. 3, 6, 12month, 1 year, 2 year:
- mean Stock returns by company
- Standard deviations for these time horizons.
2. Create a new data set for 1 and merge that with original data set by company name only.
3. Employ do loops (if/then?) or macros to create another dataset with the same calculations for 1 and 2 above? The aim is for me to understand how you're using do loops or macros for increased efficiency in future tasks like this.
i have attached the CSV file. Any input is appreciated including how you loaded the data (data step with lib reference or Proc import?)
09-23-2017 05:41 PM
Your CSV file, presumably the input data, appears to have annual returns for each PERMNO. But your rolling 2-year returns don't appear to be calculated directly from the reported 1-year returns. For instance, your file has 2-year return for MACYS 2016 as .1826, but calculating directly from the annual returns (2015=.0640, 2016=.3011), I get .1766 (=sqrt[(1+0.3011)*(1+.0640)]-1). Are you generating each of your returns independently from from monthly returns?
If you don't have monthly or quarterly returns, exactly what formula do you want to use to get the requested quarterly and semi-annual returns from the annual returns? For instance, one could calculate every quarterly return in a given year as (1+annual_return)**0.25 -1) leading to annual steps between series of 4 identical quarterly returns. Or you might use PROC EXPAND which can be asked to smooth out those values.
09-23-2017 06:00 PM
Thank you for your note, that's very helpful.
To to your point, the returns are generated independently. Let's assume that they are accurate.
basically I want to indepedenetply calculate returns and answer 1-3 above. How would I set up Proc expand? I am working on using Proc sql so any guidance on the code for the two would be very helpful.
09-23-2017 07:32 PM