Hi,
This is the graph Im looking forward to create. Not really sure if this is one x axis and 2 yaxes Or 2 X axes and 1 Y axis. Can anyone show some light towards this? Any documentation shows a method to do this?
Thanks
Hello,
Just do something similar to this.
Use PROC G3D from SAS/GRAPH.
Note that you can also run the code, as I am using a sample dataset from SASHELP that you also have.
goptions reset=all border;
title1 "Iris Species Classification";
title2 "Physical Measurement";
title3 "Source: Fisher (1936) Iris Data";
footnote1 j=l "Sepal Width not Shown";
data iris;
set sashelp.iris;
length color shape $8.;
if species="Setosa" then do; shape="club"; color="blue"; end;
if species="Versicolor" then do; shape="diamond"; color="red"; end;
if species="Virginica" then do; shape="spade"; color="green"; end;
run;
proc g3d data=iris;
note j=r f="Albany AMT/bo" "Species: " c=green "Virginica "
j=r c=red "Versicolor "
j=r c=blue "Setosa ";
scatter PetalLength*PetalWidth=SepalLength/
color=color
shape=shape
size=1.5;
run;
quit;
/* end of program */
Koen
Thanks, I have chosen Shape="pillar" to get the vertical bars, but it doesnt give solid colours, it gives only on the outline of the pillar.
Hello,
I don't know immediately how to fill the pillars with a solid color.
I guess some graphical expert will chime in and help you out on this.
Koen
Maybe @GraphGuy ?
You can certainly use PROC G3D to create such a 3D graph. The question is - should you do that and what is the benefit? If you want to be able to visually compare the bar heights across either the x or z axis (where y axis is vertical), you would get better results using a side-by-side grouped bar charts with either HGB or HGB change as the group variable. See opinions of thought leaders in the field of graphical visualization of data such as Tufte, Cleveland regarding 3D graphs. Just my 2c.
Side-by-side mean panel of 2D plots? My Stats wants a 3D bar plot as in the mock shell above. If not the proc g3d , any other solutions?
Here is an example using sashelp.cars. The Category is TYPE and Group is ORIGIN. You can use 'Hgb' and 'Hgb Change'. In this graph all are easy to compare. Also, based on what needs to be compared, you can switch usage of the Category and Group roles.
proc sgplot data=sashelp.cars(where=(type ne 'Hybrid'));
title 'Mean City Mileage by Type and Origin';
vbar type / response=mpg_city stat=mean group=origin groupdisplay=cluster
dataskin=sheen transparency=0.4;
xaxis display=(nolabel);
yaxis grid;
run;
First, why do you want to use a 3d bar chart?
What question do you want the chart to answer, and does a 3d chart do that well?
the study statisticians looks for such a figure (as below):
Not sure if there is an option to do this type of fig in SAS .
Hmm ... well, let's just go with "there's not an option to do this specific graph, with solid-color-filled bars, in SAS". If you could ask the statisticians what questions they're wanting to answer from the data, perhaps we can recommend alternate (even better) graphs. 🙂
🙂 will check !
Hello @Manj ,
There may be an option.
I see in the example graph that the two non-vertical axes have a quite discrete course (the interval-scaled axes/variables have been binned/categorized).
If you do the binning upfront and make the two "horizontal" variables discrete (character vars), you can do the plot you want.
I'm 99.5% sure I have seen a 3D-bar chart with solid filled bars on one of your many example pages. If the two x-variables are categorical (character) and the Y-variable is continuous, this is possible, no??
But I agree with @GraphGuy and @Jay54 that a 3D-plot is probably not the best option. In general statisticians (myself included) don't like them and they are not really recommended. Much nicer and more revealing and more "honest" plots can be made.
Good luck,
Koen
Hi,
I see the below link which produces the graph I was looking for. However when I tried to print as pdf it gives a different plot. Any suggestion to print as pdf file? Also how to do the y axis as the values in the dataset ? This code presents Y axis as sum or mean etc.
Sorry - that's a really old example, using activex (and using activex is discouraged these days). I wouldn't recommend using it. 🙂
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.