You may want to be a bit more explicit about what you are attempting to accomplish.
Do mean is there a way to automatically wrap text? Or to separate the text beforehand and display two variables with the same location information? Or is this to appear in a tool-tip or similar popup?
separate the text beforehand and display two variables with the same location information should solve my problem.
For example, I am displaying the number 14% (1/7) using the annotation in proc gchart. Is there a way these can be split in two lines?
Provide some minimal data in the form of a data step and the code you are currently using and we'll see if we can get what you want. It helps to know what you've done so far.
Modifying the example from http://support.sas.com/kb/45/056.html
The code below 1) adds another statistic 2) modifies the position of the first value and 3) adds value and position for second statistic to the annotate data set
/* Sum the total sales by product for each country */ proc sort data=sashelp.prdsale out=prdsale; by product country; run; proc means data=prdsale noprint; by product country; var actual; output out=meansout sum=actual_sum std=sTD; /*<= new statistic*/ run; /* Create an Annotate data set to draw */ /* the summed values for each subgroup. */ data barlabel; length function color $8 text $ 16; retain xsys ysys '2' color 'black' when 'a'; set meansout; function='label'; midpoint=product; subgroup=country; position='A'; /*<=change position from original*/ text=trim(left(put(actual_sum,dollar8.0))); output; /*<= force output of first part of labe text*/ function='label'; /* from here down add second value for same input record*/ midpoint=product; subgroup=country; position='D'; /*complementary position to above*/ text=cats('STD=',put(std,dollar8.2)); output; run; /* Define the title */ title1 "Label the Subgroups in a Horizontal Bar Chart"; /* Define the axis characteristics */ axis1 label=(angle=90 "Product") value=(justify=right); axis2 label=("Actual Sales") order=(0 to 160000 by 40000) minor=(n=3); /* Define legend options */ legend1 frame; /* Generate the graph */ proc gchart data=sashelp.prdsale; hbar product / subgroup=country sumvar=actual legend=legend1 nostats maxis=axis1 raxis=axis2 annotate=barlabel; format actual dollar8.0; run; quit; title;
Thanks your examle code is really helpful. Just one problem, is there a way we can define 1 1/2 cell below center?
I used position='E'; and position='8'; and getting the attached. How can I add space between the lines?
Thanks a lot for your help!!
length function $8;
retain style '"arial/bo"' xsys ysys '2' when 'a' size 1.5;
text=strip(round(trim(num)/trim(den)*100) || '%'); output;
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.