Dear all,
In the vline statement below, I use character variable as datalabel.
This character string now contains "National average"; instead of these characters I would like to use x-bar symbol here.
What is the best way to do this?
I tried to use the unicode in this character variable, but as a result I just get the printed code (string of characters).
First code:
data leavetop;
set leavetop;
x2="National average= *"!!strip(round(x))!!"%";
run;
Attempt with unicode:
data leavetop;
set leavetop;
x2="(*ESC*){U+0304}"!!strip(round(x))!!"%";
run;
In the vline data label attribute statement I also changed the font to "GraphUnicodeText", but this didn't change much as well.
Code of the graph:
proc sgpanel data=leavetop dattrmap=attrmap noautolegend;
panelby _NAME_/
onepanel
columns=1
rows=1
spacing=7
novarname
noborder
noheaderborder
skipemptycells
uniscale=all
headerbackcolor=white
headerattrs=(color=black size=8 weight=bold family=arial);
vbar hosp/ group=countryid groupdisplay=cluster response=col2 attrid=category fill nooutline datalabel=col2
datalabelattrs=(color=black size=5 family=arial) DATALABELFITPOLICY=none name="include";
vline hosp /response=x lineattrs=(color=darkgrey pattern=solid thickness=2) group=countryid groupdisplay=overlay splitchar="*"
datalabel=test datalabelpos=topright datalabelattrs=(size=5 color=black family=GraphUnicodeText) name="dropper" ;
vbar hosp/ group=countryid groupdisplay=cluster response=col2 attrid=category fillattrs=(transparency=1) nooutline datalabel=col2
datalabelattrs=(color=black size=5 family=arial) DATALABELFITPOLICY=none name="dropper2";
colaxis display=(noticks noline) label="Hospital" fitpolicy=rotate discreteorder=data offsetmin=0.02 offsetmax=0.02
valueattrs= (family=arial
color=black
size=7.5
style=normal)
labelattrs= (family=arial
color=black
size=9
style=normal
weight=bold);
rowaxis display=(noticks noline) label="Percent" fitpolicy=thin
values=(0 to 100 by 20)
valuesdisplay=("0%" "20%" "40%" "60%" "80%" "100%")
valueattrs= (family=arial
color=black
size=7.5
style=normal)
labelattrs= (family=arial
color=black
size=9
style=normal
weight=bold);
keylegend "include" /noborder autooutline autoitemsize valueattrs=(size=9 color=black family=arial weight=bold) titleattrs=(color=white) sortorder=ascending;
format _NAME_ $edutop.;
run;
Any suggestions on how to work around this or alternatives are much appreciated.
Kind regards,
Hello,
This shows you an example of how to get the X bar. The only thing is the TEXT statement is only compatible with the SCATTER statement and other similar plots. It's not compatible with the VLINE statement.
I think perhaps if you use GTL, i.e. LAYOUT DATAPANEL, then you may be able to overlay the VLINE equivalent and the TEXTPLOT statement, and then you would be able to add the X bar label to your plot (if you used this approach).
data prdsale2;
set sashelp.prdsale;
if _n_ = 1 then do;
response_label = actual + 30;
end;
text = "a";
run;
proc format;
value $UnicodeExample
'a'= "X(*ESC*){unicode bar}";
run;
proc sgpanel data=prdsale2;
where product in ("CHAIR" "SOFA");
format text $UnicodeExample.;
title "Yearly Sales by Product";
panelby year / spacing=5 novarname;
text x=month y=response_label text=text;
*scatter x = month y = actual / markerattrs=(symbol=redx) group=product;
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.