BookmarkSubscribeRSS Feed
statsas
Fluorite | Level 6

 

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 :

 

Sans titre.png

 

11 REPLIES 11
AhmedAl_Attar
Rhodochrosite | Level 12

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

DanH_sas
SAS Super FREQ

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.

DanH_sas
SAS Super FREQ

Also, when doing this in PROC FORMAT, you must use the default escape sequence (*ESC*). The ODS ESCAPECHAR definition is not supported there.

DanH_sas
SAS Super FREQ

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

 

 


SGPanel4.png
statsas
Fluorite | Level 6

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.

statsas
Fluorite | Level 6
No solution with SAS 9.3??
ChrisNZ
Tourmaline | Level 20

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;

aaa1.PNG

 

 

 

statsas
Fluorite | Level 6

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 :

Sans titre.png

 

I don't know what happened..it's like SAS or proc sgpanel didnt convert in rigth way the code ?

 

ballardw
Super User

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.

ChrisNZ
Tourmaline | Level 20

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.

statsas
Fluorite | Level 6

Thanks All,

 

the probleme had been fixed by using now SAS 9.4 Smiley Wink.

 

Best regards.

 

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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
  • 11 replies
  • 2464 views
  • 1 like
  • 5 in conversation