BookmarkSubscribeRSS Feed
Manj
Fluorite | Level 6

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

 

Manj_0-1620911980118.png

 

14 REPLIES 14
sbxkoenk
SAS Super FREQ

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

Manj
Fluorite | Level 6

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.

sbxkoenk
SAS Super FREQ

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

sbxkoenk
SAS Super FREQ

Maybe @GraphGuy ?

Jay54
Meteorite | Level 14

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.

Manj
Fluorite | Level 6

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?

Jay54
Meteorite | Level 14

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;

Cars.png

GraphGuy
Meteorite | Level 14

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?

 

Manj
Fluorite | Level 6

the study statisticians looks for such a figure (as below):

Manj_0-1620985631577.png

Not sure if there is an option to do this type of fig in SAS .

 

GraphGuy
Meteorite | Level 14

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. 🙂

Manj
Fluorite | Level 6

🙂 will check !

sbxkoenk
SAS Super FREQ

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.

 

@GraphGuy ,

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

Manj
Fluorite | Level 6

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.

robslink.com/SAS/democd7/col7_info.htm

GraphGuy
Meteorite | Level 14

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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 14 replies
  • 2410 views
  • 3 likes
  • 4 in conversation