BookmarkSubscribeRSS Feed
obraat
Calcite | Level 5

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? 

5 REPLIES 5
DanH_sas
SAS Super FREQ

Could you put something like "Price" or "Volume" as a consistent Y-axis label and incorporate the variable name/label into the plot title?

DanH_sas
SAS Super FREQ

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.

obraat
Calcite | Level 5

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?

ballardw
Super User

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...

obraat
Calcite | Level 5

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!

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 804 views
  • 1 like
  • 3 in conversation