Hello everyone,
I would like to add superscript "a" at value level for "Occurred".
proc format;
value occur
0="Not Occured"
2="Occured(*ESC*){unicode '1D43'x}";
run;
proc sort data= adsl out=adsl(keep= usubjid bmkfl trt01a trt01an);
by usubjid;
where bmkfl='Y';
run;
proc sort data=adbmk out=adbmk(keep=usubjid param paramcd fchg maxstom stopopfl);
by usubjid paramcd avisitn avisit;
where bmkfl='Y' and paramcd = "LO" and ablfl ne 'Y' and anl03fl='Y';
run;
data adbmk_stom;
merge adsl(in=a drop=trt01a trt01an) adbmk(in=b);
length trt01a $25;
by usubjid;
if a and b;
*aval=abs(aval);
if stopopfl ne 'Y' then do; trt01an=0; trt01a="Not Occured"; end;
else if maxstom ge 1 then do; trt01an=2; trt01a="Occured(*ESC*){unicode '1D43'x}"; end;
else trt01a='';
if trt01a ne '';
run;
data boxdat;
set adbmk_stom;
format trtan occur.;
run;
proc sort data=boxdat;
by trt01an;
run;
proc template;
define statgraph stomcyt;
begingraph;
layout overlay /
xaxisopts=(label="Occurance of Stomatitis Event" display=(label line ticks tickvalues) linearopts=(tickvaluelist=( 0 2) viewmin=0 viewmax=2)
discreteopts=(tickvaluefitpolicy=split))
yaxisopts=(type=log display=(label line ticks tickvalues)
labelsplitchar="#"
labelfitpolicy=splitalways
label = "Dicarbo hyderorotate"
linearopts=(tickvaluelist=(0 1 10 100 1000) viewmin=-0 viewmax=1000));
boxplot x=trt01a y=fchg / boxwidth=.25 fillattrs=(color=white) whiskerattrs=graphdata1 display=(CAPS FILL MEDIAN OUTLIERS);
scatterplot x=trt01a y=fchg / jitter=auto MARKERATTRS=(symbol=circle color=red) ;
endlayout;
endgraph;
end;
run;
ods listing image_dpi=300 gpath="path";
ods graphics / reset border=off width=8in height=4.5in imagename="stomcyt";
proc sgrender data=boxdat template="stomcyt" ; run;
/* format trtan occur.; */
ods listing close;
ods graphics off;
You can use a format to do this, see example below (the format will also work with SGRENDER)
See this blog https://blogs.sas.com/content/graphicallyspeaking/2015/07/29/unicode-in-formatted-data-sas-9-40m3/ for more details.
proc format;
value $myorigin
"Europe" = "Europe(*ESC*){unicode '00b9'x}"
"Asia" = "Asia(*ESC*){unicode '1D43'x}"
;
run;
proc sgplot data=sashelp.cars noautolegend ;
where origin in ("Europe", "Asia");
vbox invoice / category=origin;
scatter x=origin y=invoice / jitter;
format origin $myorigin.;
xaxis valueattrs=(size=15pt);
run;
In this case, the simplest way would be for you to use a combination of VALUES and VALUESDISPLAY (TICKVALUELIST and TICKDISPLAYLIST in GTL) to set the Unicode value instead of trying to encode it in the data. Here is a simple example. Be sure you are using a font that contains the '1D43'x glyph; otherwise, you will just get a box after "Occurred".
data test;
length cat $ 12;
input cat $ 1-12 resp;
cards;
Occurred 10
Not Occurred 20
;
proc sgplot data=test;
xaxis values=("Not Occurred" "Occurred")
valuesdisplay=("Not Occurred" "Occurred(*ESC*){unicode '1D43'x}");
scatter x=cat y=resp;
run;
In your template, in the DISCRETEOPTS you have, put the list in VALUES into the TICKVALUELIST and the VALUESDISPLAY into the TICKVALUEDISPLAY option.
For GTL, this would be in the TICKVALUEATTRS=(family="<some font family>") option inside of the appropriate axis opts (e.g. XAXISOPTS, YAXISOPTS, etc.). For the SGPLOT and SGPANEL, this would be VALUEATTRS=(family="<some font family>") on the appropriate axis statement (e.g. XAXIS, YAXIS, etc.).
You can use a format to do this, see example below (the format will also work with SGRENDER)
See this blog https://blogs.sas.com/content/graphicallyspeaking/2015/07/29/unicode-in-formatted-data-sas-9-40m3/ for more details.
proc format;
value $myorigin
"Europe" = "Europe(*ESC*){unicode '00b9'x}"
"Asia" = "Asia(*ESC*){unicode '1D43'x}"
;
run;
proc sgplot data=sashelp.cars noautolegend ;
where origin in ("Europe", "Asia");
vbox invoice / category=origin;
scatter x=origin y=invoice / jitter;
format origin $myorigin.;
xaxis valueattrs=(size=15pt);
run;
@BrunoMueller is correct, and I would recommend that approach over the tick list manipulation. This approach allows tick count and tick position independence, and also gives you the added benefit of having the data tip labels contain the Unicode characters (if you have image maps enabled).
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.