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/GRAPH and ODS Graphics
- /
- Sas Code to calculate monthly variance in daily da...

Topic Options

- Subscribe to 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
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

09-08-2012 01:31 PM

Hi,

I'm new to sas and having a hard time finding the monthly variance in the daily data set I have attached here ( i have deleted some part of the data to make the file smaller).

I want to plot monthly variance of this daily data from 2000 to 2010 so that I can see if there's a pattern.

Please be kind enough to help me with this coding.

thanks.

PS. Im using SAS 9.0

Malaka

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

09-08-2012 02:03 PM

Hi ... you posted data in a PDF file ... hard to use. How about posting a data set or text or XLS (something that is easily used). Also, the PDF has lost of columns but no variable names. The first column is date, but what column do you want analyzed (variance computation).

Here's an example using a data set from the SASHELP library (n case V9 does not have the TIMEDATA data set, it's attached) ...

*** use a SASHELP data set ... extract date from variable DATETIME;**

**data test (keep=date volume);**

**set sashelp.timedata;**

**date = datepart(datetime);**

**run;**

*** calculate monthly variance for variable VOLUME;**

**proc summary data=test nway;**

**class date;**

**var volume;**

**output out=month_var var=;**

**format date monyy.;**

**run;**

*** set graphics options;**

**goptions reset=all ftext='calibri' htext=2 gunit=pct;**

*** choose a symbol ... use a spline to fit to the monthly data;**

**symbol f='wingdings' v='6c'x i=smp66 c=blue h=2 w=2;**

**axis1 minor=none label=("MONTH-YEAR");**

**axis2 label=(a=90 'VOLUME');**

**title1 h=4 'MONTHLY VARIANCE OF VOLUME' ls=2;**

*** add white s[ace around plot;**

**title2 a=90 ls=2;**

**title3 a=-90 ls=2;**

**footnote1 ls=1;**

*** plot the values;**

**proc gplot data=month_var;**

**plot volume*date / haxis=axis1 vaxis=axis2 noframe;**

**format volume comma7.;**

**run;**

**quit;**

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

09-08-2012 02:11 PM

Hi thank you very much.

I am sorry I couldn't mention the column titles. They are: date, open, high, low, close, volume, adjclose, return.

I need the variance to be calculated for every month for every year, so I could see the pattern.

However, when I tried to attach the excel file it didn't let me...if you send me your email address I can send it to you...

I really appreciate you help.

Malaka

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

09-08-2012 03:01 PM

Hi ... did you try first converting the XLS file to a ZIP file then attaching. Give that a try.

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

09-08-2012 04:14 PM

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

09-08-2012 04:27 PM

Hi ... I posted an answer in the other THREAD that you started. Let me know if you find it and if it works for you.

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

09-08-2012 02:28 PM

Hi..

I attached the data set in a new discussion titled 'Help wit SAS code' can you please help me write this code..