Here you go:
proc means data=sashelp.class noprint;
class age sex;
var weight;
output out=meanval mean=;
ways 1;
run;
data _null_;
set meanval;
if ((age eq .) and (sex="F")) then
call symput("FMEAN", put(weight, best6.));
if ((age eq .) and (sex="M")) then
call symput("MMEAN", put(weight, best6.));
run;
proc sgplot data=sashelp.class;
vbar age / response=weight stat=mean;
inset ("Female"="&FMEAN" "Male"="&MMEAN") / border title="Avg. Weight by Gender";
run;