turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- SAS Procedures
- /
- How do I use SAS Procedure For simple Stock Analys...

Topic Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

09-23-2017 03:18 PM

Hi All,

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?)

thank you.

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to blakezen07

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

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.

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to mkeintz

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.

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to blakezen07

09-23-2017 07:11 PM

I should have mentioned that PROC EXPAND is part of SAS/ETS. Do you have the SAS/ETS license?

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to blakezen07

09-23-2017 07:32 PM

Unfortunately I don't. I used SAS EG one year ago but I only have access to SAS University edition at the moment until next month when I renew my EG license.