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

All,

Thanks in advance for looking into this!

Here is the problem - 

I am printing chinese characters in pdf using proc report and ods pdf. Initially there was no issue but as soon as I created a proc template and used the style from proc template in ods pdf, it is not able to print the characters correctly. Upon searching I think the reason is I need to "embed" the style cause there is a chance that PDF won't recognize the style+unicode [in oppose to just style which usually works with ods pdf].
Has anyone encountered a situation like this or any suggestion of how to overcome this issue?

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
CP20
Fluorite | Level 6

@Cynthia_sas  @ballardw 

 

Thanks for checking into this. 
I found out a solution. Since the SAS font template wasn't compatible with PDF font, I tried different fonts and it worked. We can provide a list of font family in the style template to overcome the issue. For e.g. 

 

replace fonts / 'titlefont2'=("<sans-serif>, Courier New, Courier",8pt)

 

Thanks once again!

View solution in original post

8 REPLIES 8
ballardw
Super User

As a minimum you should share 1) the definition of the template, one assumes you mean a style; 2) some data in the form of a data step that will behave as described; 3) the proc report code using that data; and 4) the Ods PDF statement used to create the document.

 

This is how many moving parts you have involved and without some concrete examples to work with a lot of guessing is the main result.

 

If the report worked more or less correctly without the custom style then one suspects the main issue is the style definition.

CP20
Fluorite | Level 6

Thanks ballardw for the reply!
Apologize for not providing more info.  Please see the snippet of code below. Style template is the original one but the data on which it is being used is a test data. Thanks once again!

 

ods path(prepend) work.templat(update);
proc template;
define style cust;
parent=styles.rtf;
replace fonts / 'titlefont2'=("Courier New, Courier",8pt)
'titlefont'=("Courier New, Courier",8pt)
'Strongfont'=("Courier New, Courier",8pt)
'EmphasisFont'=("Courier New, Courier",8pt)
'FixedEmphasisFont'=("Courier New, Courier",2)
'FixedStrongFont'=("Courier New, Courier",2)
'FixedHeadingFont'=("Courier New, Courier",2)
'BatchFixedFont'=("SAS Monospace,Courier New, Courier",2)
'FixedFont'=("Courier New, Courier",2)
'headingEmphasisFont'=("Courier New, Courier",8pt)
'headingFont'=("Courier New, Courier",8pt)
'docFont'=("Courier New, Courier",8pt)
'footFont'=("Courier New, Courier",8pt);
style table from table / rules=groups
frame=above
cellspacing=0.25
cellpadding=1.0;
replace header / rules=none frame=void
font = fonts('HeadingFont');
style systemtitle from systemtitle / asis=on;
style systemfooter from systemfooter / asis=on;
replace headersAndFooters from cell / font=fonts('HeadingFont')
foreground=black
background=white;
replace Body from Document "Controls the Body file. " / bottommargin = 1in
topmargin = 1in
rightmargin = 1in
leftmargin = 1in;
end;
run;

ods pdf file="C:\Users\dummy\Desktop\test.pdf" style=styles.cust notoc;
proc report data=sashelp.cars(where = (make = 'Toyota')) nowd split='*' headline headskip ls=132 ps=47 missing spacing=1 formchar(2)='_';
column model msrp MPG_City;
define model / "Model 模型";
define msrp /"MSRP" center width=10 ;
define MPG_City / "AVG 平均" center width=14 ;

run;

Cynthia_sas
SAS Super FREQ

Hi:
Just a side note. HEADLINE, HEADSKIP, LS, PS and SPACING option, as well as WIDTH= are all ignored by ODS PDF. Those are all LISTING only options that are ignored by ODS PDF.

I see the Chinese characters in your header, but are those characters available in the Courier New font that you've specified???

Cynthia

 

PS. I have not run your code yet but to test the display in Courier New and several other fonts, I compared what you originally posted with how Word displays the characters in some selected fonts without having SAS in the picture at all. Here's what I see:

Cynthia_sas_0-1596036335534.png

Note that without SAS being involved, Arial, Calibri and Courier New all put an extra character at the end of the string for Avg -- the other string looks OK to me. Is this what you say is an issue? If so, the issue is not coming from SAS or the template. It's coming from the font you're using.

CP20
Fluorite | Level 6

Hi Cynthia,

Thanks for the side note. Probably in rush I just copied over. 

At this point, I have very little knowledge of how the fonts work. From your question it seems like not all the font's support Chinese characters. So in that case, how do we check whether "Courier New" supports Chinese or in fact any other fonts? I am sorry if I am reply your question with a question.

 

 

CP20
Fluorite | Level 6

@Cynthia_sas , @ballardw 

 

This is how my output looks - 

 

CP20_0-1596036701834.png

 

Cynthia_sas
SAS Super FREQ

Hi:

Clearly you had the fonts available on your system when you typed or copied and pasted the code. That is the font you need to use. But the other issue is that you don't know whether your document viewers will have the same font on their system. So you'll need to either find a common font that has all the characters or you'll need to do font embedding. Without knowing what fonts you are using with SAS on your system, it nothing more than guessing at this point. You would be better served, I think, by opening a track with Tech Support for more directed help on using fonts for your reports.

Cynthia

CP20
Fluorite | Level 6

@Cynthia_sas  @ballardw 

 

Thanks for checking into this. 
I found out a solution. Since the SAS font template wasn't compatible with PDF font, I tried different fonts and it worked. We can provide a list of font family in the style template to overcome the issue. For e.g. 

 

replace fonts / 'titlefont2'=("<sans-serif>, Courier New, Courier",8pt)

 

Thanks once again!

Cynthia_sas
SAS Super FREQ
Hi:
Please revisit your template code. The REPLACE statement was deprecated in SAS 9.2 and the preferred usage is either the CLASS or STYLE statement. If you are still running SAS 9.1, then REPLACE was usable syntax in template code. In newer versions of SAS, you should try not to use REPLACE.
Cynthia

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 8 replies
  • 1894 views
  • 3 likes
  • 3 in conversation