HI All,
I want to make a chart with what I'm thinking of as a "nested axis".
For example, conisder a barchart of sashelp.shoes with x=product y=sales.
Now suppose I want the x-axis to be nested, so x-axis could be Region*Subsidiary*Product.
And maybe the x-axis would look like (ASCII Art):
------------------------------------------------------------------------------------------------------------------------------------------------- shoes socks shoes socks shoes socks shoes socks Boston NewYork Paris Madrid North America Europe
Is there a straightforward way to do that?
Looks like a similar approach is:
proc template; define statgraph myplot; begingraph; layout datapanel classvars=(Region Subsidiary) / rows=1 headerlabeldisplay=value ; layout prototype ; barchart x=product y=Sales /stat=mean; endlayout; endlayout; endgraph; end; run; proc sgrender data=sashelp.shoes (where=(Subsidiary IN ("Chicago" "Los Angeles" "Madrid" "Geneva") and product=: "Men" ) ) template=myplot ; run;
Wondering if folks would suggest another approach for this sort of grouping / nesting of an x-axis?
Second question: Assuming I stick with the DATAPANEL approach, is there a way to get the value of the classvars to display on the bottom of each cell, rather than the top? (in 9.3)
Thanks,
--Q.
If a two-level axis is acceptable, it is easy. Use the SGPANEL procedure.as shown in the 3rd graph in this blog article:
Thanks Sanjay,
That blog post is great!
Users were hoping for a three-level axis, so I Iiked that datapanel supports n levels.
But I like your SGPANEL / DATALATTICE approach, it's definitely closer to what we drew on the white board. I think I can convince them to put the third level of nesting on the /group=.
--Q.
Ack, I pay the price for over-simplifying my example.
In real life I want to do this with a box plot, not a bar chart. I tried:
proc template; define statgraph myplot3; begingraph; layout gridded; layout datalattice columnvar=region / headerlabeldisplay=value columnheaders=bottom border=false ; layout prototype / ; boxplot =subsidiary y=sales; endlayout; endlayout; endlayout; endgraph; end; run;
And it throws:
ERROR 823-580: Computed plots and expressions cannot be used in this layout.
Fair enough, the docs say that as well. Boxplot is a no-go for layout prototype.
Then I tried SGPanel and it works:
proc sgpanel data=sashelp.shoes (where=(Subsidiary IN ("Chicago" "Los Angeles" "Madrid" "Geneva") and product=: "Men" ) ) ; panelby Region/ layout=columnlattice novarname noborder colheaderpos=bottom; vbox sales/group=product category=subsidiary; colaxis display=(nolabel); rowaxis grid; run;
I haven't used SGPANEL. I had assumed it was generating GTL code behind the scenes, like SGPLOT. So I thought it wouldn't work with vbox. But it does work. Then I thought "Oh, let me see what GTL code SGPANEL is generating", and there is no TMPLOUT= option.
So a few questions:
1. SGPanel isn't generating GTL code???
2. Is there a way I can do what SGPanel is doing, with GTL code?
-- Was thinking even though layout prototype doesn't like box plots, looks like perhaps I could roll my own, using e.g. layout lattice, with one layout overlay block for each box plot
I'm not averse to following the SGPANEL route a bit. It's just that often I end up doing enough crazy stuff with reference lines and html drill downs that I wind up back in GTL-land.
Thanks,
-Q.
If thsi is a custom graph, you can annotate the macro level label under the axis.
The VBAR can be clustered without the stacks.
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.