Graphics Programming

Data visualization using SAS programming, including ODS Graphics and SAS/GRAPH. Charts, plots, maps, and more!
BookmarkSubscribeRSS Feed
zdblizar
Fluorite | Level 6

Hello!

 

I'd like to add a line to the chart produced from the code below. I want it to the serve the purpose of highlighting the difference between the two bars (in terms of the height of each bar). Does anyone know what additions I need to incorporate in the code below?

 

title height=20pt "Forecast Error by Method";

title2 height=17pt "Overall SBU Level for Year &Year";

proc sgplot data=Append_Table2_Year;

styleattrs datacolors=(red blue);

vbar Method / Response=Avg_Error_by_Method stat=mean datalabel datalabelattrs=(size=15pt) group=Method;

xaxis display=(nolabel)

labelattrs=(size=15)

valueattrs=(size=13);

yaxis labelattrs=(size=15) max=15;

keylegend / titleattrs=(size=12) valueattrs=(size=12) location=outside;

run;

 

Thanks!

-Z

1 REPLY 1
DanH_sas
SAS Super FREQ

The simplest way is to add a VLINE using the same variables as the VBAR:

 

title height=20pt "Forecast Error by Method";
title2 height=17pt "Overall SBU Level for Year &Year";
proc sgplot data=Append_Table2_Year;
styleattrs datacolors=(red blue);
vbar Method / Response=Avg_Error_by_Method stat=mean datalabel datalabelattrs=(size=15pt) group=Method;
vline Method / Response=Avg_Error_by_Method stat=mean group=Method;
xaxis display=(nolabel)
labelattrs=(size=15)
valueattrs=(size=13);
yaxis labelattrs=(size=15) max=15;
keylegend / titleattrs=(size=12) valueattrs=(size=12) location=outside;
run;

Hope this helps!

Dan

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

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
  • 1 reply
  • 3026 views
  • 1 like
  • 2 in conversation