BookmarkSubscribeRSS Feed
sidello
Calcite | Level 5

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,

 

 

 

1 REPLY 1
djrisks
Barite | Level 11

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;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 879 views
  • 0 likes
  • 2 in conversation