Hi all,
I have a sgplot in a macro that is looped to various filters in my dataset. This all works great, except for when one of the filters has (almost) no data. Here's the macro:
%MACRO PLOT_WL(PHASE); ods graphics / noborder width=100%; proc sgplot data=input_workload_graph noborder; where upcase(fase)=upcase(&PHASEASE); vline date / response=amount_2wd lineattrs=(color=lightgrey thickness=3pt pattern=solid) legendlabel="2 workdays"; vline date / response=amount_3wd lineattrs=(color=orange thickness=3pt pattern=solid) legendlabel="3+ workdays"; xaxis display=(nolabel); yaxis display=(nolabel); keylegend / noborder; run;
I have two questions about the options for the axes:
Output now (first question)2. If the filter results in smaller numbers, the y-axis displays decimal numbers. I'd like the y-axis to increment in whole numbers. I tried setting the valuesformat to this but this just displays the same 6 points on the y-axis pictured below but rounded to either 0 or 1. Ideally, the graph below only has two y-axis points. The 0 and 1.
Output now (second question)
Thanks in advance for the help!
One thing I might consider that could potentially solve both problems is instead of looping over values is to, possibly restructure the data, use SGPANEL with your Fase variable, suitably subsetted for all the graphs, as the panel by variable. Options in Sgpanel could make your graphs as one column and not in a single panel. The default behavior is uniform axis for both x and y variables. So unless your range of values has one vertical axis showing values of 0 to 1 and another that wants 0 to 10000 this may work better than the approaches that would involve
1) check on your subset number of values for number of y values and set a different yaxis statement conditionally
2) check on your subset range of values and determine appropriate yaxis values based on range
I really understand this issue because I have done similar in the past before we had Sgpanel and had to ineffect implement some of the Sgpanel behavior with macro coding and lots of it.
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.