BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Abdulla1
Quartz | Level 8

Hello all

I've created the bar chart below, and I wonder if it is possible to let the bar chart show be both the frequency and the percentage ?

code"

PROC SGPLOT DATA = sashelp.cars;
VBAR type /group=origin;
RUN;

"

function output:

Abdulla1_0-1668697507530.png

wanted output examples

Abdulla1_2-1668697914184.png

thanks

 

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User
PROC SGPLOT DATA = sashelp.cars nocycleattrs;
VBAR type /group=origin;
VBAR type /group=origin y2axis stat=percent ;
RUN;

Ksharp_0-1668772344732.png

 

View solution in original post

5 REPLIES 5
Reeza
Super User
What is the denominator for the percentage? Overall or Per type?
Abdulla1
Quartz | Level 8

if it is possible to do it per type that would be great. 😄

 

Abdulla1
Quartz | Level 8

i think in order for it to work with the percentage per type we need to write the value inside each colored portion cause otherwise the percent access  needs a different bar as the percentage scale changes along the type
I found a way of adding the percent (out of total) in color like this but this losses the information of what each section of the bar represent (origin data in my example).

I wish I can keep write the percentage (and adjust it to pertype) value in the boxes instead of the frequency.

code :

PROC SGPLOT DATA = sashelp.cars;
VBAR type /group=origin COLORSTAT=PCT SEGLABEL;
RUN;

Abdulla1_1-1668709643778.png

 

 

Ksharp
Super User
PROC SGPLOT DATA = sashelp.cars nocycleattrs;
VBAR type /group=origin;
VBAR type /group=origin y2axis stat=percent ;
RUN;

Ksharp_0-1668772344732.png

 

Abdulla1
Quartz | Level 8

y2axis

that is just a great option.

thank you .

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 499 views
  • 2 likes
  • 3 in conversation