BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
bob021
Calcite | Level 5

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;

1 ACCEPTED SOLUTION

Accepted Solutions
GraphGuy
Meteorite | Level 14

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

7 REPLIES 7
GraphGuy
Meteorite | Level 14

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

bob021
Calcite | Level 5

Hi Robert

Thank you very much. Your solution was helpful.

Thanks again.

bob021
Calcite | Level 5

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

GraphGuy
Meteorite | Level 14

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.

bob021
Calcite | Level 5

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

GraphGuy
Meteorite | Level 14

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.

bob021
Calcite | Level 5

Yes, sorting was helpful.

Thank you very much.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 7 replies
  • 1692 views
  • 6 likes
  • 2 in conversation