BookmarkSubscribeRSS Feed
aggdmf
Calcite | Level 5

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:

 

  1. The first problem is that when there is no data to display the line for 0 is not at the x-axis but in the centre of the graph. How do I get it to align with the x-axis? I do not want to set 0 as a fixed minimum as for some filters this wouldn't apply. See below for how it looks now.

Output now (first question)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)Output now (second question)

Thanks in advance for the help!

 

1 REPLY 1
ballardw
Super User

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.

 

sas-innovate-white.png

Special offer for SAS Communities members

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.

 

View the full agenda.

Register now!

Creating Custom Steps in SAS Studio

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 1 reply
  • 1547 views
  • 0 likes
  • 2 in conversation