Dears,
I'm using sgpanel procedure to get a graphs by panel treatmnt.
and I want to have a "TRT A (5x1010 ) " and "TRT B (5x1011 )" and "Placebo" in the labels of treatment.
I used TRT A 5x10{sup '10'} but it's not work and i used also unicode but not thing is working like if sgpanel not accepte Unicode in labels of pnels.
here is my code :
PROC FORMAT ;
VALUE dy 1 = '1 '
29='29'
OTHER =' ';
value trtn 1= "TRT A 5x10{sup '10'}"
2="TRT B 1x10{sup '11'}"
3='Placebo';
RUN;
PROC SGPANEL DATA=im02 sganno=anno noautolegend pad=(left=10% bottom=10%);
TITLE "Title 1";
FORMAT bas1c dy.;
FORMAT vis dy.;
format trtgpn trtn.;
PANELBY TRTGPN / columns=3 layout=COLUMNLATTICE sparse SPACING=3 novarname colheaderpos=top uniscale=all;;
......
Run;
what i Got :
Try this,
ODS ESCAPECHAR='^';
PROC FORMAT ;
VALUE dy 1 = '1 '
29='29'
OTHER =' ';
value trtn 1= "TRT A 5x10^{super 10}"
2="TRT B 1x10^{super 11}"
3='Placebo';
RUN;
Hope it helps,
Ahmed
The SUP and SUB keywords do not work for ODS Graphics when doing inline escapements in PROC FORMAT. Only the Unicode function is supported, starting in SAS 9.4m3.
Also, when doing this in PROC FORMAT, you must use the default escape sequence (*ESC*). The ODS ESCAPECHAR definition is not supported there.
Assuming you are running SAS 9.4m3 or greater, you can do it like this:
proc format;
value $sup
'F'="TRT A 5x10(*ESC*){unicode '00b9'x}(*ESC*){unicode '2070'x}"
'M'="TRT B 1x10(*ESC*){unicode '00b9'x}(*ESC*){unicode '00b9'x}"
;
run;
proc sgpanel data=sashelp.class;
format sex $sup.;
panelby sex / novarname headerattrs=GraphUnicodeText;
scatter x=weight y=height;
run;
I set the header font to a more fully-defined Unicode font to handle the superscript 0. Otherwise, it might have shown up just as a box.
Hope this helps!
Dan
Thanks Ahmed ,Thanks Dan,
for sup as Dan Sayed is not supported in GTL.
unfortunatly Dan I'm using SAS9.3..and i use your code and it's not work, but what I don't understand that unicode works in annotate but not in format and sgpanel!!
do you have another solution?
Thanks in advance.
Unicode support is a bit inconsistent as it was clipped on at various stages.
A summary of its implementation (note the bug with sas/graph) :
%***************** ODS GRAPH **********;
proc format ;
value $sup_sg
'F'="TRT A 5x10(*ESC*){unicode '00b9'x}(*ESC*){unicode '2070'x}"
'M'="TRT B 1x10(*ESC*){unicode '00b9'x}(*ESC*){unicode '00b9'x}" ;
ods graphics on / width=320px height=240px;
proc sgpanel data=SASHELP.CLASS;
format SEX $sup_sg.;
panelby SEX / novarname headerattrs=GraphUnicodeText;
scatter x=WEIGHT y=HEIGHT;
run;
%***************** ODS REPORT **********;
ods escapechar='^';
proc format ;
value $sup_ods 'F'="TRT A 5x10^{super 10}"
'M'="TRT B 1x10^{super 11}" ;
proc freq data=SASHELP.CLASS;
format SEX $sup_ods.;
table SEX;
run;
%***************** SAS/GRAPH **********;
%let a=%sysfunc(unicodec(TRT A 5x10, utf16b),$hex40.)00b92070;
%let b=%sysfunc(unicodec(TRT B 1x10, utf16b),$hex40.)00b900b9;
legend value=(font="arial unicode ms/unicode" "&a"x "&b"x) ;
goptions ypixels=240 xpixels=320;
proc gplot data=SASHELP.CLASS;
plot WEIGHT*AGE=SEX/legend=legend1;
run;
quit;
Thanks ChrisZ,
I follow your recommandations here are my code (just to try) :
%let b=%sysfunc(unicodec(TRT B 1x10, utf16b),$hex40.)00b900b9;
PROC FORMAT ;
VALUE dy 1 = '1 '
29='29'
OTHER =' ';
value trtn 1="&b x"
2='TRT A (1x10^11 vp)'
3='Placebo';
RUN;
PROC SGPANEL DATA=im02 SGANNO=anno noautolegend pad=(left=10% bottom=10%);
title "title 1";
FORMAT trtgpn trtn.;
PANELBY TRTGPN / columns=3 LAYOUT=COLUMNLATTICE sparse SPACING=3 novarname colheaderpos=bottom uniscale=all;;
.......................;
.......................;
run;
And I got :
I don't know what happened..it's like SAS or proc sgpanel didnt convert in rigth way the code ?
We can't "try it" we don't have your data.
Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.
You didn't follow the recommendations as:
1- you moved the x suffix inside the quotes
2- this method with the hex suffix is not to be used for sg procedures anyway. These use the first example's syntax.
Thanks All,
the probleme had been fixed by using now SAS 9.4 .
Best regards.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.