I frequently produce chart outputs with two to three proc sgplot charts to a single page (landscape orientation, charts stacked one on top of the other).
These charts are typically intraday stock (trade and quote) price/volume data, made for many tickers/dates. I can make the charts/macro calls very quickly, but often the most time consuming part of producing the charts is reviewing each chart individually and making manual adjustments in the calls to align the y-axes (i.e., adjusting the formatting of the y-axis labels so the plot areas and x-axis gridlines of both charts stay aligned). All charts are plotted with time on the x-axis, but the y-axis is some price/volume variable, and as you can likely imagine with stocks, volume can vary wildly across stocks and even across the same stock. Is there a way to automate this alignment within the charting macro to avoid doing it manually?
Could you put something like "Price" or "Volume" as a consistent Y-axis label and incorporate the variable name/label into the plot title?
Sorry, you were talking about the tick values, not the axis label. Would you be opposed to having these plot in one display? That way, the axes have the ability to auto-align themselves based on the content of each plot.
Correct, yes, talking about the tick values displayed on the y-axis. I often plot multiple price and multiple volume variables so I prefer to keep them on separate charts.
Even so, usually when I plot them together and one is on the y-axis and the other is on y2, I have to manually align the axes so they have the same number of tick marks/so their gridlines are aligned. This is aside from my main question but since you've brought it up, is there a way around having to do this manual adjustment?
If the X and Y axis variables are the same, or could reasonable be made the same, I would be tempted to place all the data into one data set with variable to order the graphs. Then use SGPANEL with that order variable. By default the axis will by uniscale, be the same.
If your existing data set has a variable like Ticker then Ticker might be the Panelby variable...
The x-axes are always the same (time) but the y-axes differ (price, volume, etc.) which is why I want them in separate charts. And I am also always working within the same dataset, with all of the data sorted by time.
Not sure if sgpanel is really what I'm looking for but it looks like it'll be worth a try - thanks!
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.