BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
rbikes
Obsidian | Level 7

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;
1 ACCEPTED SOLUTION

Accepted Solutions
rbikes
Obsidian | Level 7

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:

View solution in original post

7 REPLIES 7
rbikes
Obsidian | Level 7

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;
Jay54
Meteorite | Level 14

In format definition, you must use the full default escape character - (*ESC*).

Rick_SAS
SAS Super FREQ

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"

 

rbikes
Obsidian | Level 7

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.

DanH_sas
SAS Super FREQ

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;
Jay54
Meteorite | Level 14

This feature is only available with SAS 9.40M3 onwards.

rbikes
Obsidian | Level 7

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:

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
  • 2206 views
  • 0 likes
  • 4 in conversation