BookmarkSubscribeRSS Feed
Mscarboncopy
Pyrite | Level 9

Hello,

 

I am trying to generate a 3D chart for percent and need some help to finalize it.

 

 

Mscarboncopy_0-1745323703469.png

 

I have tried several things and am not able to remove the extra points in the axis1. 

I would also like to:

Add the percent inside each bar values are 50/ 18/32

 

datalines;
 
ID 
Greetings
1
1
2
1
3
1
4
1
5
1
6
1
7
1
8
1
9
1
10
1
11
1
12
2
13
2
14
2
15
3
16
3
17
3
18
3
19
3
20
3
21
3
22
                  .
23
                  .
24
                  .
25
2
;
 
I am using this code to generate a percent graph and wanted it to be a 3D graph.
 
Proc format;
Value Gre
1 = 'Hello'
2 = 'Hi'
3 = 'Dear';
run;
 
 
Data want;
Set have;
Format Greetings Gre. ;
run;
proc Gchart Data=have;
vbar3d Greetings / TYPE=PERCENT;
axis1 order=(1 2 3); *not sure why this does not work;
run;
 
Thank you so much!
 
 
17 REPLIES 17
PaigeMiller
Diamond | Level 26

I think the FREQ option in PROC GCHART VBAR3D statement will work.

 

Generally speaking, 3D charts are a misleading way to display data. See https://medium.com/@purohitpraveen/data-vizualization-why-3d-charts-are-a-terrible-idea-32657fbb928e... You might want to consider the regular old 2D VBAR charts.

--
Paige Miller
Mscarboncopy
Pyrite | Level 9

Thanks. The link did not work.

 

ballardw
Super User

Try adding MAJOR=3 to the Axis definition. That forces the appearance of exactly 3 major tick marks. Order affects that the order values are displayed. Major affects the number of displayed tick marks (or Minor the the number of minor ticks between each pair of Major ticks).

 

Better for many reasons would be to switch to Proc SGPLOT unless you are stuck with a version of SAS 8 or earlier.

Ksharp
Super User

Calling @GraphGuy  (a.k.a Robert.Allision ) ,since you are asking some special feature with 3D chart.

Or you could try PROC SGPLOT + GTL Annotation Facility (sganno= option) to get this 3D chart, but that need to write many code to finish it.

 

P.S. Why not use PROC SGPLOT + VBAR to simplify this question as Paige and ballardw pointed out ?

Mscarboncopy
Pyrite | Level 9

Thank you! It was requested that I create a 3D chart like the one I am showing. I had originally created one with PROC SGPLOT + VBAR as everyone suggested (and it would be my preference) but the graph was seen as too plain.

PaigeMiller
Diamond | Level 26

@Mscarboncopy wrote:

Thank you! It was requested that I create a 3D chart like the one I am showing. I had originally created one with PROC SGPLOT + VBAR as everyone suggested (and it would be my preference) but the graph was seen as too plain.


You should point out that 2D charts are more readable and less likely to produce confusion on the part of the person who is viewing the chart; compared to a 3D chart. The correct link is https://medium.com/@purohitpraveen/data-vizualization-why-3d-charts-are-a-terrible-idea-32657fbb928e

--
Paige Miller
DanH_sas
SAS Super FREQ

For this case, can you use the DISCRETE option on VBAR3D?

DanH_sas
SAS Super FREQ

Also, if you interested in a 3D-like look with 2D readability, you could try something like this:

SGPlot.png

data test;
input value;
cards;
1
1
1
1
2
2
3
3
3
3
3
3
;
run;

proc sgplot data=test;
vbar value / stat=percent dataskin=pressed;
run;
Mscarboncopy
Pyrite | Level 9

Thank you @DanH_sas  This is great.

Is there any way I can add the percentage value to the top of each bar?

DanH_sas
SAS Super FREQ

Add the DATALABEL option to the VBAR statement. You can also use the FILLATTR=(color=<some color>) if you want to change the color.

Mscarboncopy
Pyrite | Level 9

@DanH_sasPerfect. Last question. Is there a way to round up the percentage?  Right now I have 18.18% and 31.8% for 2 of the value points. I would like to have them display 18% and 32%. Thank you again!

DanH_sas
SAS Super FREQ

On the SGPLOT statement, set PCTNDEC=0.

Mscarboncopy
Pyrite | Level 9

@DanH_sas Is there a similar function to round up percentage for

proc Gchart Data want;

vbar3d var/ TYPE=Percent

 

I've read so much and I can't find a way to be able to round the percentage in this case.  I learned how to do everything else I wanted like change the points in the axis, color, width of the bars, add the percent value to the bars. But I can't find a way to round the percentage in this case.

DanH_sas
SAS Super FREQ

You can do it using the STATFMT option on the VAR3D statement.

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

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
  • 17 replies
  • 1050 views
  • 9 likes
  • 5 in conversation
OSZAR »