Data visualization with SAS programming

SAS 9.1 proc gplot order axis

Accepted Solution Solved
Reply
Contributor
Posts: 60
Accepted Solution

SAS 9.1 proc gplot order axis

Hi can somebody help mi with this.

My question is how to put two dimension  on horizontal axis wk and year to get proper order from wk 42/2013 to 1/2014.

This script was fine until first week of 2014.

I tried to make new variable with compress (year|| "*"||wk)  and then to split axis by * but there was error : All variables must be the same type for overlay request.

Thank you in advance

data pass_fail;                                                                                                                     

  

   input wk actual pass fail year;                                                                                               
   datalines;
1423     42302014
4269296915142013
4393449334102013
447329732272013
4582638248152013
4682668252142013
477525752052013
481029910276232013
49110591105632013
50104441044312013
51117761177602013
525015501412013

;

run;

data plan;

set pass_fail;
plan = 8400; 
format ratio percent7.;
ratio = pass / (pass + fail ) ;
week=wk-.13;

run;

goptions reset=ALL gsfmode=replace htext=30pt cback=white border htitle=32pt htext=16pt ftext="Arial/bold";

axis1 label=(a=90 h=25pt 'Actual /Plan') order=(0 to 12000 by 2000) minor=none offset=(0,0);

axis2 label=(a=90 h=25pt'Ratio') order=(.82 to 1.00 by .01) minor=none offset=(0,0);

axis3 label=( h=25pt'Week') minor=none offset=(0,10) value=(t=1 ' ');

symbol1 value=dot cv=purple height=2 interpol=join width=5 color=purple ;

symbol2 value=none interpol=needle width=50 color=red;

symbol3 value=none interpol=needle width=50 color=blue;

footnote h = 25pt c = black 'Actual ' c=Red f=marker 'U'

h = 25pt  c=black f='Arial/bold' '  Plan  ' c=blue  f=marker 'U'
h = 25pt  c=black f='Arial/bold' '  Ratio  ' c=purple   '____';

proc gplot data=plan;

plot actual*wk=2 plan*week=3 / overlay

vzero vaxis=axis1 haxis=axis3 autovref cvref=graydd;

plot2 ratio*wk=1 /  vaxis=axis2 ;

run;

quit;


Accepted Solutions
Solution
‎01-08-2014 08:25 AM
SAS Employee
Posts: 963

Re: SAS 9.1 proc gplot order axis

Gplot doesn't support a 2-level axis (like a grouped bar chart, with year & week).

In your case, I'd recommend using real SAS 'date' values, and applying a 'week' format (such as weeku, weekv, or weekw).  Here's a page describing thesw formats:

http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002604217.htm

View solution in original post


All Replies
Solution
‎01-08-2014 08:25 AM
SAS Employee
Posts: 963

Re: SAS 9.1 proc gplot order axis

Gplot doesn't support a 2-level axis (like a grouped bar chart, with year & week).

In your case, I'd recommend using real SAS 'date' values, and applying a 'week' format (such as weeku, weekv, or weekw).  Here's a page describing thesw formats:

http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002604217.htm

Contributor
Posts: 60

Re: SAS 9.1 proc gplot order axis

Hi Robert

Thank you very much. Your solution was helpful.

Thanks again.

Contributor
Posts: 60

Re: SAS 9.1 proc gplot order axis

Rpbert

Just one more question. As you can see on image there is two lines for Ratio.

In previous example I used week = wk - ..13; to avoid this.

This was worked because wk was formated as numeric. Now I use  different format, weekv5., which not allow me to do the same.

proc gplot data=plan;

plot actual*wk=2 plan*week=3 / overlay

vzero vaxis=axis1 haxis=axis3 autovref cvref=graydd;

plot2 ratio*wk=1 /  vaxis=axis2 ;

run;

Capture.JPG

Is there any way how to fix this and get proper result?

Thank you in advance

SAS Employee
Posts: 963

Re: SAS 9.1 proc gplot order axis

The underlying date values are still numeric, so you can still use the "subtract an offset" technique to get one of the needle-bars to move to the left. But the offset will have to be a much larger number now - experiment with it a little, and see what offset works best for your situation.

Contributor
Posts: 60

Re: SAS 9.1 proc gplot order axis

Thank you for quick answer.

My problem is in two RATIO lines. It should be just one line showing ratio for period 3013/2014 .

Now I have one line for each year. Not sure where the problem is.

Thanks

SAS Employee
Posts: 963

Re: SAS 9.1 proc gplot order axis

Ahh - now I understand.

I think you'll need to sort your data by the date variable. Since you have the data from the 2nd year first in your data, it starts drawing the line there, and then when it gets to the data from the first year it then connects the points on the right of the graph to the points back on the left of the graph (creating the extra/stray line across the graph). Gplot simply connects the points in the order they are in the data.

Contributor
Posts: 60

Re: SAS 9.1 proc gplot order axis

Yes, sorting was helpful.

Thank you very much.

Post a Question
Discussion Stats
  • 7 replies
  • 649 views
  • 6 likes
  • 2 in conversation