BookmarkSubscribeRSS Feed
david27
Quartz | Level 8

Hello,

 

We have this code from -- https://support.sas.com/rnd/datavisualization/yourGraphs/businessQuick/vbar/#s1=2

 

ods listing style=listing;
ods graphics / width=5in height=2.81in;

title 'Mileage by Origin and Type';
proc sgplot data=sashelp.cars(where=(type ne 'Hybrid'));
  vbar origin / response=mpg_city group=type groupdisplay=cluster 
    stat=mean dataskin=gloss;
  xaxis display=(nolabel noticks);
  yaxis grid;
run;

Can we have the exact same chart but with vbar=origin one followed by other.-- Not Stacked.

So a bar chart for Asia followed by Europe followed by USA.

 

Please advise.

 

Thanks

2 REPLIES 2
Reeza
Super User

Try adding a BY statement for the ORIGIN. You may need to sort the data by origin before you can do that.

 

ods listing style=listing;
ods graphics / width=5in height=2.81in;

proc sort data=sashelp.cars out=cars; by origin;
run;

title 'Mileage by Origin and Type';
proc sgplot data=cars(where=(type ne 'Hybrid'));
by origin;
  vbar type/ response=mpg_city
    stat=mean dataskin=gloss;
  xaxis display=(nolabel noticks);
  yaxis grid;
run;

Making a random guess, that's what I think you want.

 


@david27 wrote:

Hello,

 

We have this code from -- https://support.sas.com/rnd/datavisualization/yourGraphs/businessQuick/vbar/#s1=2

 

ods listing style=listing;
ods graphics / width=5in height=2.81in;

title 'Mileage by Origin and Type';
proc sgplot data=sashelp.cars(where=(type ne 'Hybrid'));
  vbar origin / response=mpg_city group=type groupdisplay=cluster 
    stat=mean dataskin=gloss;
  xaxis display=(nolabel noticks);
  yaxis grid;
run;

Can we have the exact same chart but with vbar=origin one followed by other.-- Not Stacked.

So a bar chart for Asia followed by Europe followed by USA.

 

Please advise.

 

Thanks


 

ballardw
Super User

Are you asking for 3 separate charts with each one showing Asia, one Europe and one USA or something else?

Maybe

proc sgpanel data=sashelp.cars(where=(type ne 'Hybrid'));
  panelby origin/ rows=3;
  vbar type / response=mpg_city groupdisplay=cluster 
    stat=mean dataskin=gloss;
  colaxis display=(nolabel noticks);
  rowaxis grid;
run;
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
  • 2 replies
  • 774 views
  • 0 likes
  • 3 in conversation