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

Dear all,

I have a proc gchart with vbar, group and subgroup. The type is percent. If I don't add anything then 100% is the whole chart. If I add the option g100 then 100% is within one group. Now, my customer wants 100% per bar in this chart. Is that possible?

Best wishes

Eva

1 ACCEPTED SOLUTION

Accepted Solutions
data_null__
Jade | Level 19



         


Is that it?

proc summary data=sashelp.cars (where=(make in ("Audi","BMW"))) nway;
  
class make type cylinders;
   var enginesize;
   output out=summary sum=;
   run;
proc freq data=summary noprint;
  
by make type;
   tables cylinders / out=pct nocum;
  
weight enginesize;
   run;
proc gchart data=pct;
   vbar make / group = type
     
subgroup = cylinders
     
sumvar=percent
     
type=sum
      ;
   run;
  
quit;

View solution in original post

5 REPLIES 5
ballardw
Super User


A code example of what you attempted would be helpful.

Eva
Quartz | Level 8 Eva
Quartz | Level 8

proc gchart data=sashelp.cars (where=(make in ("Audi","BMW")));

     vbar make / freq = enginesize

                    group = type

                    subgroup = cylinders

                    type=percent

                    g100 /* effect: one group=100% , but I need one bar=100% */

                    ;

run;

quit;

data_null__
Jade | Level 19



         


Is that it?

proc summary data=sashelp.cars (where=(make in ("Audi","BMW"))) nway;
  
class make type cylinders;
   var enginesize;
   output out=summary sum=;
   run;
proc freq data=summary noprint;
  
by make type;
   tables cylinders / out=pct nocum;
  
weight enginesize;
   run;
proc gchart data=pct;
   vbar make / group = type
     
subgroup = cylinders
     
sumvar=percent
     
type=sum
      ;
   run;
  
quit;
Eva
Quartz | Level 8 Eva
Quartz | Level 8

Yes! I always searched for a vbar Option... But a proc freq before the proc gchart is best 🙂

Thanx for your help data_null_.

ballardw
Super User

I'm not sure quite what you want but if each bar should total to 100 across the cylinder count you may need to process your data a bit before taking it to GCHART.

Maybe this is what you are looking for?

proc freq data=sashelp.cars (where=(make in ("Audi","BMW"))) noprint;
   table make* type *cylinders/ outpct out=work.cars;
run;

proc gchart data=work.cars (where=(make in ("Audi","BMW")));
     vbar make /    sumvar=Pct_row
                    group = type
                    subgroup = cylinders
                    type=sum
                    ;
    label pct_row='Percent of Engine Cylinders' ;
run;
quit;

SAS INNOVATE 2024

Innovate_SAS_Blue.png

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. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 5 replies
  • 635 views
  • 0 likes
  • 3 in conversation