BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
RAVI2000
Lapis Lazuli | Level 10

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;

RAVI2000_1-1684784956614.png

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
BrunoMueller
SAS Super FREQ

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;

View solution in original post

7 REPLIES 7
DanH_sas
SAS Super FREQ

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;
RAVI2000
Lapis Lazuli | Level 10
Can I do something similar using proc template & SGRENDER?
DanH_sas
SAS Super FREQ

In your template, in the DISCRETEOPTS you have, put the list in VALUES into the TICKVALUELIST and the VALUESDISPLAY into the  TICKVALUEDISPLAY option.

RAVI2000
Lapis Lazuli | Level 10
where do we exactly specify the font?
DanH_sas
SAS Super FREQ

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.).

BrunoMueller
SAS Super FREQ

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;
DanH_sas
SAS Super FREQ

@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). 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 7 replies
  • 716 views
  • 5 likes
  • 3 in conversation