Data visualization with SAS programming

Sas Code to calculate monthly variance in daily data and to plot

Reply
Frequent Contributor
Posts: 91

Sas Code to calculate monthly variance in daily data and to plot

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

Valued Guide
Posts: 723

Re: Sas Code to calculate monthly variance in daily data and to plot

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;

Attachment
Attachment
Frequent Contributor
Posts: 91

Re: Sas Code to calculate monthly variance in daily data and to plot

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

Valued Guide
Posts: 723

Re: Sas Code to calculate monthly variance in daily data and to plot

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

Frequent Contributor
Posts: 91

Re: Sas Code to calculate monthly variance in daily data and to plot

Hi

Here's the data..

Thanks

Attachment
Valued Guide
Posts: 723

Re: Sas Code to calculate monthly variance in daily data and to plot

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.

Frequent Contributor
Posts: 91

Re: Sas Code to calculate monthly variance in daily data and to plot

Hi..

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

Post a Question
Discussion Stats
  • 6 replies
  • 579 views
  • 4 likes
  • 2 in conversation