BookmarkSubscribeRSS Feed
BenConner
Pyrite | Level 9


Hi,

I'm sure this has been answered before but I'm not even sure what to search on.  When you have a graph displaying multiple lines (say sales by month and year, with the months along the x axis and each line on the graph representing a year), how do you control which line is 'on top'?

It would be nice to see the most recent year on the top if the data is close from one year to the next.

The graph in question uses spline smoothing in a set of SYMBOLn statements with different symbols (star, triangle, etc.) to represent the data points.  Currently some 2012 month points are buried by prior year points.  These are displayed as html graphs so hovering over the month in question returns the prior year value.

Thanks!

--Ben

4 REPLIES 4
ballardw
Super User

It has been awhile since I played with this but I think it has to do with the order the SYMBOL statements are associated with values. Have you tried sorting the data by year (or Z in general). Or sometines sort by the FORMATTED value of Z.

IIRC if my first data point were associated with 2012 then it gets the Symbol1 statment and if the next record is 2010 it gets Symbol2. Then SAS displays them in symbol order.


BenConner
Pyrite | Level 9

Hi,

Thanks for taking a stab at it.  I have tried re-ordering the data and the Symbol(n) statements with no change in the graph.  May need to open a ticket with the Graph folks.

--Ben

GraphGuy
Meteorite | Level 14

Typically, when I want to make sure a certain line is "in front" of the others, I re-arrange my data so that instead of using "plot y*x=z" I can use "plot y1*x=symbol-num y2*x=symbol-num y3*x=symbol-num".  And the lines are drawn in the order specified (the last one is drawn last, and is "in front").

Here's an example with exaggerated/thick lines to demonstrate (note that the symbol2 red line is on top):

symbol1 value=none interpol=join width=7 color=blue;
symbol2 value=none interpol=join width=7 color=red;
symbol3 value=none interpol=join width=7 color=pink;

proc gplot data=sashelp.stocks (where=(stock='IBM'));
plot
low*date=1
high*date=3
close*date=2
/ overlay;
run;

BenConner
Pyrite | Level 9

Oh!  I hadn't thought of using the overlay facility.  Good idea!  I'll give that a shot.

Thanks!

--Ben

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 4 replies
  • 700 views
  • 0 likes
  • 3 in conversation