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
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.
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
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;
Oh! I hadn't thought of using the overlay facility. Good idea! I'll give that a shot.
Thanks!
--Ben
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.