Hey I would like to create a graph using the command:
PROC SGPLOT DATA = work.GruppierungAlter;
VBAR PHQg_gr / GROUP = OHIPg_gr ;
RUN;
I would like to divide each of the columns again into male and female gender or different age groups.
Can anyone help?
Thanks
If you already have a group variable, you can't further group within the bars on gender or age.
You could, I suppose, in the data set named work.GruppierungAlter, create a new variable which is the concatenation of OHIPg_gr and gender, or the concatenation of OHIPg_gr and age, and then use these new variables as the GROUP= variable in PROC SGPLOT.
Alternatively, you could use PROC SGPANEL to put the different genders in side-by-side bar charts, or to put the different age groups in side-by-side bar charts.
VBAR in PROC SGPANEL allows you to have a GROUP variable which could be sex or anything else you want.
Perhaps you want an SGpanel with Panelby PHQg_gr , Vbar OHIPg_gr /group (sex/ age / other variable)
or make the original Group variable a PanelBy.
If you don't have many values for PHQg_gr you could force all the plot on a single row with the /rows=1 option in the Panelby statement. May have to play with some barwidth and other spacing options.
Hard to say, as you didn't tell us what didn't work.
How is it possible to divide each columns in male/female?
As I said, PROC SGPANEL allows a GROUP= option
@LeniLesola wrote:
It doesn't work unfortunately.
If i try it with this step:
proc SGPLOT data = work.GruppierungAlter;
vbar OHIPg_gr/group = PHQg_gr;
run;
quit;
How is it possible to divide each columns in male/female?
Not at all related to what I suggested. I suggested Proc SGPANEL.
Something like:
proc sgpanel data = work.GruppierungAlter; panelby OHIPg_gr; vbar PHQg_gr /group = sex; run; quit;
Maybe.
Without data we cannot test your code to make more targeted solutions.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.