Hi. I would like to create this below graph, but the region (east and west) should be lattice display not stacked and show the datalabel for each region. Thank you.
legend1 position=(right bottom inside) across=1 label=none
shape=bar(.10in,.10in);
proc gchart data=sashelp.prdsale;
hbar product / DISCRETE type=sum sumvar=actual sum sumlabel='Counts' descending group=quarter
nozero subgroup=region
maxis=axis1 raxis=axis2 gaxis=axis3 legend=legend1 noframe PATTERNID=subgroup ;
run;
If you are expecting the graph as below then try the code
legend1 position=(right bottom inside) across=1 label=none shape=bar(.10in,.10in);
proc gchart data=sashelp.prdsale;
hbar region / DISCRETE type=sum sumvar=actual sum sumlabel='Counts' descending group=product
maxis=axis1 raxis=axis2 gaxis=axis3 legend=legend1 noframe PATTERNID=midpoint ;
run;
Thanks. The "Quarter" category is not showing here. How can I include that?
Please check now, I used the subgroup=quarter in the code below
legend1 position=(right bottom inside) across=1 label=none shape=bar(.10in,.10in);
proc gchart data=sashelp.prdsale;
hbar region / DISCRETE type=sum sumvar=actual sum sumlabel='Counts' descending group=product subgroup=quarter
maxis=axis1 raxis=axis2 gaxis=axis3 legend=legend1 noframe PATTERNID=midpoint ;
run;
For each quarter there should be data label, too. How can I do that? Thanks!
Hope you are fine with the below, used annotation dataset as below
goptions reset=global;
data barlabel;
length function color $8;
retain xsys ysys '2' color 'magenta' when 'a';
set sashelp.prdsale;
function='label';
midpoint=region;
group=product;
subgroup=quarter;
text=' '||strip(put(quarter,best.));
run;
legend1 position=(right bottom inside) across=1 label=none shape=bar(.10in,.10in) mode=protect;
proc gchart data=sashelp.prdsale;
hbar region / DISCRETE type=sum sumvar=actual sum sumlabel='Counts' descending group=product subgroup=quarter
maxis=axis1 raxis=axis2 gaxis=axis3 legend=legend1 noframe PATTERNID=midpoint annotate=barlabel;
run;
Sorry, I wanted to show not stacked the quarterly data and the actual counts for each latticed displayed bars.
Are you fine with this
legend1 position=(right bottom inside) across=1 label=none shape=bar(.10in,.10in) mode=protect;
proc gchart data=sashelp.prdsale;
hbar quarter / DISCRETE type=sum sumvar=actual sum sumlabel='Counts' descending group=product subgroup=region
maxis=axis1 raxis=axis2 gaxis=axis3 legend=legend1 noframe PATTERNID=subgroup ;
run;
Can you take prdsales and show what you actually want either by drawing it or doing it in Excel and then we can try to help you out.
Have you tried SGPLOT or are you using GCHART for a specific reason - the graphic types from SGPLOT are nicer and higher quality and I find it significantly easier to work with in comparison to SAS/GRAPH.
@Zula wrote:
Right now the bar subgroup (quarter) displayed by stacked—-I want lattice displayed and at the each bar quarter the counts should show not the actual quarter values. Thank you.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.