Data visualization with SAS programming

LAYOUT DATAPANEL exact X axis length.

Reply
Respected Advisor
Posts: 3,768

LAYOUT DATAPANEL exact X axis length.

I want to specify the exact length for each X axis or the overall size of the column panels.  I am trying to make two calls to GRENDER produce a 3 column data panels plots that are compareable. 

SAS Super FREQ
Posts: 864

LAYOUT DATAPANEL exact X axis length.

Is it the physical axis size or the axis data range that matters for the comparison? If the data range is sufficient, you could determine the min/max for each axis in a datastep, set those values in macro variables, and set the macro variables on the VIEWMIN / VIEWMAX options in the axis options. You could instead use dynamics on these options (for better template reuse) and pass the macro variable values on the DYNAMIC statement in PROC SGRENDER. If you use these values for each call to PROC SGRENDER, you will create comparative panels based on unified data ranges. Let me know if this meets your needs.

Thanks!

Dan

Respected Advisor
Posts: 3,768

Re: LAYOUT DATAPANEL exact X axis length.

Yes, sorry I was not complete in my description, it is the physical length that I want to specify.  I've used GSCALE to produce a TICKVALUESEQUENCE using all data

Because the width of the Y axis labels are different with each call to GRENDER, the Xaxis panels are also slightly different size. 

So I thought if I could specify the X axis length I could have my cake and eat it too.

On a slightly different subject GSCALE seems to use a different algorithm from that used in GTL, same data different ticks .  Do you know if I could make it produce the same Tick Sequence or can I call the GTL function directly.

Respected Advisor
Posts: 3,768

Re: LAYOUT DATAPANEL exact X axis length.

bump.

SAS Employee
Posts: 963

Re: LAYOUT DATAPANEL exact X axis length.

If there's not a way to do what you're wanting in sgrender, perhaps you could resort to the traditional SAS/Graph Proc Gplot, where you can specify a 'length=' in the axis statement?  Not exactly what you originally asked for, but perhaps a work-around that will let you accomplish the end-goal?

For example, here's some output where I use Gplot, and specify ...

  

axis1 length=2.3in offset=(0,0) order=(0 to 60 by 10) minor=none;

axis2 length=2.3in offset=(0,0) order=(0 to 60 by 10) minor=none;

And then panel the graphs into 3 columns using "ods htmlpanel"

http://robslink.com/SAS/democd52/gas_class_2012.htm

http://robslink.com/SAS/democd52/gas_class_2012_info.htm

Respected Advisor
Posts: 3,768

Re: LAYOUT DATAPANEL exact X axis length.

Thanks Robert I knew the option I wanted was in the AXIS statement but I was hopeing to stay with GTL.  I was NOT aware of HTML panel.  Is there RTFPANEL?

SAS Employee
Posts: 963

Re: LAYOUT DATAPANEL exact X axis length.

I'm not 100% sure, but I've never heard of "rtfpanel", so I think this is an html-only thing.

I guess if you had to have rtf output, you could use Gplot & set the length on the axis statement, and then greplay the plots into a greplay template with 3 columns (but this would require a lot more manual work, than the automatic layout you would get with 'ods htmlpanel').

I guess it all depends on what is the desired end-result, and what of that is hard & fast "requirements" versus what is "preferences"?

SAS Super FREQ
Posts: 864

Re: LAYOUT DATAPANEL exact X axis length.

The GSCALE function cannot be used in the axisopts directly; however, you could stick the result of the function in macro variables that you can use in the template. Also, it may be possible that GSCALE returns nice start and end points that are beyond the end of the data. Therefore, I would also set the start and end macro variables on the VIEWMIN and VIEWMAX options to make sure the axis expands to accomodate your tick range.

Hope this helps,

Dan

Respected Advisor
Posts: 3,768

Re: LAYOUT DATAPANEL exact X axis length.

DanH@sas wrote:

The GSCALE function cannot be used in the axisopts directly; however, you could stick the result of the function in macro variables that you can use in the template. Also, it may be possible that GSCALE returns nice start and end points that are beyond the end of the data. Therefore, I would also set the start and end macro variables on the VIEWMIN and VIEWMAX options to make sure the axis expands to accomodate your tick range.

Hope this helps,

Dan


Thanks Dan, I understand that GSCALE cannot be called within GTL.  I have all that working. 

I don't understand your next comment.  It appears to me that GSCALE will always returns a tick range that includes all data.  I don't know if that is documented but it appears be working that way.

GTL on the other hand when scaling the tick range appears to produce tick values that may not include the min and/max data points but the min and max are still plotted.  This produces a nicer looking plot.

For example given a data range of -199.680 to 167.340 GSCALE(NINCR= -4) gives START=-200 END=200 INCREMENT=100, while GTL using default threshold and view parameters gives -200 to 100 by 100 with the max at 167.34 still displayed on the graph.

Ideally I would like to call the GTL scale routine directly and have it give me START END and INC like GSCALE does using the apparently more sophisticated algorithm.  Got any ideas about that?

SAS Super FREQ
Posts: 864

Re: LAYOUT DATAPANEL exact X axis length.

My concern was that GSCALE might return starting and ending tick marks beyond the range of the data, and that those tick marks would sometimes not appear unless the axis range was extended accordingly with VIEWMIN/VIEWMAX. If those tick marks fall within the tick value THRESHOLDMIN/MAX (see doc under LINEAROPTS), then they are drawn even if they go beyond the data range. Your "200" was outside the threshold, so it was dropped. However, if you add the START and END values to the VIEWMIN/MAX options and use TICKVALUESEQUENCE to specify the start, end, and increment, you should get what GSCALE recommended (unless there is a tick value collision, which will cause thinning). Does this answer your question?

Thanks!
Dan

Post a Question
Discussion Stats
  • 9 replies
  • 682 views
  • 0 likes
  • 3 in conversation