BookmarkSubscribeRSS Feed
piao
Calcite | Level 5

I have below code and output the figure in RTF. Some Chinese characters are truncated in the legend but all English characters are showed.

Is there anything wrong with the template?

 

Thanks.

piao_0-1666698919709.png

 

 

 

%macro RTF_Template2(escapechar=@,_StFont=Courier New, _nbpt=8 );

%global line line2 tablestyle liststyle graphstyle lastfootnote1 lastfootnote2 lastfootnote3;

%*--------------------------------------------------------------------------*;
%* Step 01: Macro Variables for table display *;
%*--------------------------------------------------------------------------*;

%let line="&escapechar.R/RTF'\fs0\brdrb\brdrs\brdrw20";
%let line2=%str(&escapechar.R/RTF%'\fs0\brdrb\brdrs\brdrw10);


/* font for table and listing */
%let tablestyle=kltnr_8_uk;
%let liststyle=kltnr_8_uk;
%let graphstyle=kltnr_9_uk;

%*--------------------------------------------------------------------------*;
%* Step 02: define fonts for tables and listings *;
%*--------------------------------------------------------------------------*;

*****fonts for tables;

ods path work.templat(update) sasuser.templat(read)
sashelp.tmplmst(read);

***** define rtf template;
proc template;
define style styles.kltnr_9_uk;
parent=styles.rtf;
replace fonts/
'TitleFont'= ("&_StFont", &_nbpt.pt)
'TitleFont2'= ("&_StFont", &_nbpt.pt, Bold)
'FixedFont'= ("&_StFont", &_nbpt.pt, Bold)
'StrongFont'= ("&_StFont", &_nbpt.pt, Bold)
'docFont'= ("&_StFont", &_nbpt.pt)
'footFont'=("&_StFont", &_nbpt.pt)
'EmphasisFont' = ("&_StFont", &_nbpt.pt,normal)
'headingFont' = ("&_StFont", &_nbpt.pt)

'headingEmphasisFont' = ("&_StFont", &_nbpt.pt)
'FixedEmphasisFont' = ("&_StFont", &_nbpt.pt)
'FixedStrongFont' = ("&_StFont", &_nbpt.pt)
'FixedHeadingFont' = ("&_StFont", &_nbpt.pt)
'BatchFixedFont' = ("&_StFont", &_nbpt.pt);

replace color_list /
'link' = blue
'bgH' = white
'fg' = black
'bg' = white;

replace body from Document/
bottommargin=1.26in
topmargin=1.26in
rightmargin=2in
leftmargin=2in;

style table from output/
frame = void
rules = groups
cellpadding = 1
cellspacing=0
borderwidth=0
outputwidth=100%;

style table from container/
frame=void
rules=groups
cellpadding=.4pt
cellspacing=0pt
borderwidth=.4pt
asis=on;
/* style table/*/
/* frame=hsides*/
;

class GraphFonts
"Fonts used in graph styles" /
'GraphDataFont' = ("&_StFont",&_nbpt.pt, demi_bold)
'GraphValueFont' = ("&_StFont",&_nbpt.pt, demi_bold)
'GraphLabelFont' = ("&_StFont",&_nbpt.pt, demi_bold)
'GraphFootnoteFont' = ("&_StFont",&_nbpt.pt, demi_bold)
'GraphTitleFont' = ("&_StFont",&_nbpt.pt, demi_bold)
'GraphAnnoFont' = ("&_StFont",&_nbpt.pt, demi_bold)
'GraphUnicodeFont' = ("&_StFont",&_nbpt.pt, demi_bold)
'GraphLabel2Font' = ("&_StFont",&_nbpt.pt, demi_bold)
'GraphTitle1Font' = ("&_StFont",&_nbpt.pt, demi_bold)
'NodeTitleFont' = ("&_StFont",&_nbpt.pt, demi_bold)
'NodeLabelFont' = ("&_StFont",&_nbpt.pt, demi_bold)
'NodeInputLabelFont'= ("&_StFont",&_nbpt.pt, demi_bold)
'NodeDetailFont' = ("&_StFont",&_nbpt.pt, demi_bold);

style GraphData1 from GraphData1 /
markersymbol = "circle" linestyle=1;
style GraphData2 from GraphData2 /
markersymbol = "Asterisk" linestyle=2;
style GraphData3 from GraphData3 /
markersymbol = "triangle" linestyle=20;

style GraphData4 from GraphData4 /
markersymbol = "square" linestyle=33;
style GraphData5 from GraphData5 /
markersymbol = "X" linestyle=41;
style GraphData6 from GraphData6 /
markersymbol = "Star" linestyle=5;

style GraphData7 from GraphData7 /
markersymbol = "Diamond" linestyle=8;
style GraphData8 from GraphData8 /
markersymbol = "circlefilled" linestyle=28;
style GraphData9 from GraphData9 /
markersymbol = "Plus" linestyle=15;
style GraphData10 from GraphData10 /
markersymbol = "starfilled" linestyle=2;
style GraphData11 from GraphData11 /
markersymbol = "trianglefilled" linestyle=20;

style GraphDataText/font=("&_StFont", 9pt, normal);
style GraphLabelText/font=("&_StFont", 9pt, normal);
style GraphValueText/font=("&_StFont", 9pt, normal);

end;
run;


%mend;
%RTF_Template2;
proc format;
value $sex
'F'='十分士大夫士大夫的'
'M'='fgdgdfghjfdgsdg'
;
run;

options device=emf ;
ods rtf file="test.rtf" style=kltnr_9_uk nogtitle nogfootnote;

proc sgplot data=sashelp.class;
vbar age/group=sex response=height stat=mean groupdisplay=cluster limits=upper ;
keylegend / title='' ;
format sex $sex. ;
run;

2 REPLIES 2
ballardw
Super User

You may have to set a longer default length for the format to display.

The Chinese characters actually take more bytes to store and display than ASCII.

Try this and see if it helps:

 

proc format;
value $sex (default=40)
'F'='十分士大夫士大夫的'
'M'='fgdgdfghjfdgsdg'
;
run;

I can't really test that as I'm not going to mess with the encoding settings to deal with the Chinese character set. If that displays what you want but has more white space than you need experiment with reducing the 40.

 


@piao wrote:

I have below code and output the figure in RTF. Some Chinese characters are truncated in the legend but all English characters are showed.

Is there anything wrong with the template?

 

Thanks.

piao_0-1666698919709.png

 

 

 

%macro RTF_Template2(escapechar=@,_StFont=Courier New, _nbpt=8 );

%global line line2 tablestyle liststyle graphstyle lastfootnote1 lastfootnote2 lastfootnote3;

%*--------------------------------------------------------------------------*;
%* Step 01: Macro Variables for table display *;
%*--------------------------------------------------------------------------*;

%let line="&escapechar.R/RTF'\fs0\brdrb\brdrs\brdrw20";
%let line2=%str(&escapechar.R/RTF%'\fs0\brdrb\brdrs\brdrw10);


/* font for table and listing */
%let tablestyle=kltnr_8_uk;
%let liststyle=kltnr_8_uk;
%let graphstyle=kltnr_9_uk;

%*--------------------------------------------------------------------------*;
%* Step 02: define fonts for tables and listings *;
%*--------------------------------------------------------------------------*;

*****fonts for tables;

ods path work.templat(update) sasuser.templat(read)
sashelp.tmplmst(read);

***** define rtf template;
proc template;
define style styles.kltnr_9_uk;
parent=styles.rtf;
replace fonts/
'TitleFont'= ("&_StFont", &_nbpt.pt)
'TitleFont2'= ("&_StFont", &_nbpt.pt, Bold)
'FixedFont'= ("&_StFont", &_nbpt.pt, Bold)
'StrongFont'= ("&_StFont", &_nbpt.pt, Bold)
'docFont'= ("&_StFont", &_nbpt.pt)
'footFont'=("&_StFont", &_nbpt.pt)
'EmphasisFont' = ("&_StFont", &_nbpt.pt,normal)
'headingFont' = ("&_StFont", &_nbpt.pt)

'headingEmphasisFont' = ("&_StFont", &_nbpt.pt)
'FixedEmphasisFont' = ("&_StFont", &_nbpt.pt)
'FixedStrongFont' = ("&_StFont", &_nbpt.pt)
'FixedHeadingFont' = ("&_StFont", &_nbpt.pt)
'BatchFixedFont' = ("&_StFont", &_nbpt.pt);

replace color_list /
'link' = blue
'bgH' = white
'fg' = black
'bg' = white;

replace body from Document/
bottommargin=1.26in
topmargin=1.26in
rightmargin=2in
leftmargin=2in;

style table from output/
frame = void
rules = groups
cellpadding = 1
cellspacing=0
borderwidth=0
outputwidth=100%;

style table from container/
frame=void
rules=groups
cellpadding=.4pt
cellspacing=0pt
borderwidth=.4pt
asis=on;
/* style table/*/
/* frame=hsides*/
;

class GraphFonts
"Fonts used in graph styles" /
'GraphDataFont' = ("&_StFont",&_nbpt.pt, demi_bold)
'GraphValueFont' = ("&_StFont",&_nbpt.pt, demi_bold)
'GraphLabelFont' = ("&_StFont",&_nbpt.pt, demi_bold)
'GraphFootnoteFont' = ("&_StFont",&_nbpt.pt, demi_bold)
'GraphTitleFont' = ("&_StFont",&_nbpt.pt, demi_bold)
'GraphAnnoFont' = ("&_StFont",&_nbpt.pt, demi_bold)
'GraphUnicodeFont' = ("&_StFont",&_nbpt.pt, demi_bold)
'GraphLabel2Font' = ("&_StFont",&_nbpt.pt, demi_bold)
'GraphTitle1Font' = ("&_StFont",&_nbpt.pt, demi_bold)
'NodeTitleFont' = ("&_StFont",&_nbpt.pt, demi_bold)
'NodeLabelFont' = ("&_StFont",&_nbpt.pt, demi_bold)
'NodeInputLabelFont'= ("&_StFont",&_nbpt.pt, demi_bold)
'NodeDetailFont' = ("&_StFont",&_nbpt.pt, demi_bold);

style GraphData1 from GraphData1 /
markersymbol = "circle" linestyle=1;
style GraphData2 from GraphData2 /
markersymbol = "Asterisk" linestyle=2;
style GraphData3 from GraphData3 /
markersymbol = "triangle" linestyle=20;

style GraphData4 from GraphData4 /
markersymbol = "square" linestyle=33;
style GraphData5 from GraphData5 /
markersymbol = "X" linestyle=41;
style GraphData6 from GraphData6 /
markersymbol = "Star" linestyle=5;

style GraphData7 from GraphData7 /
markersymbol = "Diamond" linestyle=8;
style GraphData8 from GraphData8 /
markersymbol = "circlefilled" linestyle=28;
style GraphData9 from GraphData9 /
markersymbol = "Plus" linestyle=15;
style GraphData10 from GraphData10 /
markersymbol = "starfilled" linestyle=2;
style GraphData11 from GraphData11 /
markersymbol = "trianglefilled" linestyle=20;

style GraphDataText/font=("&_StFont", 9pt, normal);
style GraphLabelText/font=("&_StFont", 9pt, normal);
style GraphValueText/font=("&_StFont", 9pt, normal);

end;
run;


%mend;
%RTF_Template2;
proc format;
value $sex
'F'='十分士大夫士大夫的'
'M'='fgdgdfghjfdgsdg'
;
run;

options device=emf ;
ods rtf file="test.rtf" style=kltnr_9_uk nogtitle nogfootnote;

proc sgplot data=sashelp.class;
vbar age/group=sex response=height stat=mean groupdisplay=cluster limits=upper ;
keylegend / title='' ;
format sex $sex. ;
run;


 

piao
Calcite | Level 5

Thank you. But it doesn't work. Actually when I use below format, it is still truncated.

proc format;
value $sex (default=40)
'F'='十分士'
'M'='fgdgdfghjfdgsdg'
;
run;

 

piao_0-1666711261398.png

 

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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
  • 2 replies
  • 744 views
  • 0 likes
  • 2 in conversation