BookmarkSubscribeRSS Feed
Zula
Obsidian | Level 7

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;

10 REPLIES 10
Jagadishkatam
Amethyst | Level 16

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;

 

image.png

Thanks,
Jag
Zula
Obsidian | Level 7

Thanks. The "Quarter" category is not showing here. How can I include that? 

Jagadishkatam
Amethyst | Level 16

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;

 

image.png

Thanks,
Jag
Zula
Obsidian | Level 7

For each quarter there should be data label, too. How can I do that? Thanks!

Jagadishkatam
Amethyst | Level 16

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;  

 

 

image.png

Thanks,
Jag
Zula
Obsidian | Level 7

Sorry, I wanted to show not stacked the quarterly data and the actual counts for each latticed displayed bars.

Jagadishkatam
Amethyst | Level 16
Sorry I am not clear, could you please give more details
Thanks,
Jag
Zula
Obsidian | Level 7
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.
Jagadishkatam
Amethyst | Level 16

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;  

 

image.png

Thanks,
Jag
Reeza
Super User

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.

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Mastering the WHERE Clause in PROC SQL

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.

Discussion stats
  • 10 replies
  • 1062 views
  • 1 like
  • 3 in conversation