Hi everyone, I have this fomat that has a unicode for greater or equal to and would like to use a chatagory in a graph similar to the output of this example code below.
Thanks ahead of time!
proc format; value age 1="< 5 Years" 2="^{unicode '2265'x} 5 Years"; run; data race; infile datalines dlm=','; input age score; datalines; 1,12 2,14 1,17 1,10 2,7 2,4 1,6 2,8 ; run; proc template; define statgraph plot_race; begingraph /border=false designwidth=800px designheight=500px; layout overlay/walldisplay=none yaxisopts=(label="Scroe" linearopts=(tickvaluelist=(0 5 10 15 20) viewmin=0 viewmax=20)) xaxisopts=(Label="age" type=linear display=(line ticks tickvalues) linearopts=( tickvaluelist=(1 2) tickvalueformat=age. tickvaluefitpolicy=none)); scatterPlot x=eval(0.08*rannor(57)+age) y=score / name="sp1" markerAttrs=GraphData1 dataTransparency=0.5; boxplot x=age y=score /boxwidth=0.2 display=(caps mean median) meanAttrs=(symbol=plus); endlayout; endgraph; end; run; ods rtf file="Test Score" style=myjournal BODYTITLE_AUX nogtitle nogfootnote; ods graphics/ height= 4in width=6.4in; title1 "Results"; proc sgrender data=race template=plot_race; run; ods rtf close; ods listing;
I found a solution, it was from moving the
linearopts=(
tickvaluelist=(1 2)
tickdisplaylist= ("< 5 Years" "^{unicode '2265'x} 5 Years") tickvaluefitpolicy=none
)
unicode from the format to the tickdisplaylist. It looks like the following:
Sorry, I do know about ods escapechar, but it still doesn't work. ( updated code with it in there)
proc format; value age 1="< 5 Years" 2="^{unicode '2265'x} 5 Years"; run; data race; infile datalines dlm=','; input age score; datalines; 1,12 2,14 1,17 1,10 2,7 2,4 1,6 2,8 ; run; options orientation=landscape; ods escapechar='^'; proc template; define statgraph plot_race; begingraph /border=false designwidth=800px designheight=500px; layout overlay/walldisplay=none yaxisopts=(label="Scroe" linearopts=(tickvaluelist=(0 5 10 15 20) viewmin=0 viewmax=20)) xaxisopts=(Label="age" type=linear display=(line ticks tickvalues) linearopts=( tickvaluelist=(1 2) tickvalueformat=age. tickvaluefitpolicy=none)); scatterPlot x=eval(0.08*rannor(57)+age) y=score / name="sp1" markerAttrs=GraphData1 dataTransparency=0.5; boxplot x=age y=score /boxwidth=0.2 display=(caps mean median) meanAttrs=(symbol=plus); endlayout; endgraph; end; run; ods rtf file="Test Score" style=myjournal BODYTITLE_AUX nogtitle nogfootnote; ods graphics/ height= 4in width=6.4in; title1 "Results"; proc sgrender data=race template=plot_race; run; ods rtf close; ods listing;
In format definition, you must use the full default escape character - (*ESC*).
Use the full escape designation:
proc format;
value age
1="< 5 Years"
2="(*ESC*){unicode '2265'x} 5 Years";
run;
See the article "Unicode in Formatted Data - SAS 9.40M3"
Thank you Sanjayand RIck for responding. But uncofcentialy when I added in the (*ESC*) within the format it still donest work. I am running SAS 9.3 TS level 1M2 on windows
proc format;
value age
1="< 5 Years"
2="(*ESC*){unicode '2265'x} 5 Years";
run;
data race;
infile datalines dlm=',';
input age score;
datalines;
1,12
2,14
1,17
1,10
2,7
2,4
1,6
2,8
;
run;
proc template;
define statgraph plot_race;
begingraph /border=false designwidth=800px designheight=500px;
layout overlay/walldisplay=none
yaxisopts=(label="Scroe"
linearopts=(tickvaluelist=(0 5 10 15 20) viewmin=0 viewmax=20))
xaxisopts=(Label="age" type=linear display=(line ticks tickvalues)
linearopts=( tickvaluelist=(1 2)
tickvalueformat=age.
tickvaluefitpolicy=none));
scatterPlot x=eval(0.08*rannor(57)+age) y=score / name="sp1"
markerAttrs=GraphData1
dataTransparency=0.5;
boxplot x=age y=score /boxwidth=0.2 display=(caps mean median)
meanAttrs=(symbol=plus);
endlayout;
endgraph;
end;
run;
ods rtf file="C:\Users\[NAME]\Downloads\Test Score" style=myjournal BODYTITLE_AUX nogtitle nogfootnote;
ods graphics/ height= 4in width=6.4in;
options orientation=landscape;
ods escapechar='^';
title1 "Results";
proc sgrender data=race template=plot_race;
run;
ods rtf close;
ods listing;
if that helps.
Since this is an "aggregating" format, you should not put it on the TICKVALUEFORMAT option. Put it on the FORMAT statement in PROC SGRENDER:
proc sgrender data=race template=plot_race;
format age age.;
run;
This feature is only available with SAS 9.40M3 onwards.
I found a solution, it was from moving the
linearopts=(
tickvaluelist=(1 2)
tickdisplaylist= ("< 5 Years" "^{unicode '2265'x} 5 Years") tickvaluefitpolicy=none
)
unicode from the format to the tickdisplaylist. It looks like the following:
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.