Data visualization with SAS programming

Unicode in a format to change output of proc template and proc sgender

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 12
Accepted Solution

Unicode in a format to change output of proc template and proc sgender

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;

Accepted Solutions
Solution
‎06-14-2016 03:05 PM
Occasional Contributor
Posts: 12

Re: Unicode in a format to change output of proc template and proc sgender

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


All Replies
Occasional Contributor
Posts: 12

Re: Unicode in a format to change output of proc template and proc sgender

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;
SAS Super FREQ
Posts: 1,141

Re: Unicode in a format to change output of proc template and proc sgender

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

SAS Super FREQ
Posts: 3,630

Re: Unicode in a format to change output of proc template and proc sgender

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"

 

Occasional Contributor
Posts: 12

Re: Unicode in a format to change output of proc template and proc sgender

[ Edited ]

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.

SAS Super FREQ
Posts: 925

Re: Unicode in a format to change output of proc template and proc sgender

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;
SAS Super FREQ
Posts: 1,141

Re: Unicode in a format to change output of proc template and proc sgender

This feature is only available with SAS 9.40M3 onwards.

Solution
‎06-14-2016 03:05 PM
Occasional Contributor
Posts: 12

Re: Unicode in a format to change output of proc template and proc sgender

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:

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 7 replies
  • 532 views
  • 0 likes
  • 4 in conversation