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
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
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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.
Ready to level-up your skills? Choose your own adventure.