NESUG 16 Posters PS005 Fonts and Special Characters in SAS – It’s All Greek to Me Doug Lassman, PRA International, Lenexa, KS Description Copyright Sign Registered Sign Degree Sign Plus-Minus Sign Superscript Two Superscript Three Micro Sign Superscript One Fraction One Quarter Fraction One Half Fraction Three Quarters ABSTRACT Fonts and special characters are increasingly more important as SAS output is no longer limited to uniform space type on line printed pages. This paper discusses the use of fonts and special characters with SAS output as well as SAS/Graph output. The methods of accessing special characters and using them with SAS output will be covered. Also, the use of fonts and special characters as well as creating fonts in SAS/Graph will be explained. Character © ® ° ± ² ³ µ ¹ ¼ ½ ¾ Keystroke Alt+0169 Alt+0174 Alt+0176 Alt+0177 Alt+0178 Alt+0179 Alt+0181 Alt+0185 Alt+0188 Alt+0189 Alt+0190 FONTS AND SPECIAL CHARACTERS IN SAS/GRAPH The following program can be run that displays the SAS/Graph fonts. It first gets the list of the fonts from the sashelp.fonts catalog and then creates a pdf file output of the font using PROC GFONT. The Simplex and Greek fonts are displayed in Appendix 1. INTRODUCTION This paper discusses the use of fonts and special characters in SAS output as well as SAS/Graph output. These allow you to enhance your output easily since most output is no longer confined to uniform space type on line printed pages. First, accessing special characters will be discussed. Then the use of fonts and special characters in SAS/Graph will be covered. A program that displays the available fonts will be presented, then using special characters in SAS/Graph will be explained. Finally, a program that creates a user defined font will show another way that special characters are available. These concepts and programs have been developed in PC SAS in the Windows environment. The concepts and programs may or may not apply to other platforms. proc catalog c=sashelp.fonts; contents out=fonts; run; quit; data _null_; set fonts; file 'c:\fontlist.sas'; if type='FONT' then put '%dispfont(' name ')'; run; SPECIAL CHARACTERS IN SAS OUTPUT Special characters such as symbols or Greek letters are often needed in SAS output. The superscript characters are particularly helpful with footnotes. In the Windows environment while using certain fonts, some of these characters are easily available via a Windows program or a keystroke sequence. For Windows fonts such as Arial, Courier New, SAS Monospace, and Times New Roman, the following special characters are available using the Character Map program or the specified keystroke sequence by holding down the ALT key and entering the 4 digit number on the keypad and then releasing the ALT key. Other characters can be found in the Character Map program displays and can be similarly accessed. %macro dispfont(font); goptions reset=all device=pdf gsfname=pdfname; filename pdfname "c:\&font..PDF"; title1 f=simplex h=2.5 "Appendix 1 -" "Font: &font"; proc gfont name=&font nobuild romfont=swissl showroman; run; quit; %mend; %include "c:\fontlist.sas"; 1 NESUG 16 Posters data plot; input x y; cards; 1 10 2 5 3 7 4 2 5 6 6 8 ; run; This next program illustrates some difficulties with special characters. The Greek and math symbols aren’t available in the simplex font and are not printing correctly, and a superscript is desired in the title to reference the footnote. Appendix 2 shows the problem plot. data plot; input x y; cards; 1 10 2 5 3 7 4 2 5 6 6 8 ; run; goptions reset=all device=pdf gsfname=pdfname gunit=pct; filename pdfname "c:\goodplot.PDF"; symbol1 i=j v=dot h=1; axis2 label=(f=simplex h=3 a=90 "Concentration (mg)") order=0 to 10 by 1 value=(f=simplex h=3); axis1 label=(f=simplex h=3 "Dose (" f=greek "m" f=simplex "g)") value=(f=simplex h=3) minor=none; goptions reset=all device=pdf gsfname=pdfname gunit=pct; filename pdfname "c:\badplot.PDF"; symbol1 i=j v=dot h=1; axis2 label=(f=simplex h=3 a=90 'Concentration (mg)') order=0 to 10 by 1 value=(f=simplex h=3); axis1 label=(f=simplex h=3 'Dose (µg)') value=(f=simplex h=3) minor=none; proc gplot data=plot; plot y*x / haxis=axis1 vaxis=axis2 ; title1 f=simplex h=2.5 "Appendix 2 - Plot With Problems"; title2 f=simplex h=2.5 "Mean Concentration1 by Dose (µg)"; footnote1 f=simplex h=2.5 "1Concentration after Steady-State" " Dosing (7±1 Days)"; run; quit; proc gplot data=plot; plot y*x / haxis=axis1 vaxis=axis2 ; title1 f=simplex h=2.5 "Appendix 2 - Corrected Plot"; title2 f=simplex h=2.5 "Mean Concentration" h=2 move=(+0,+1.5) "1" h=2.5 move=(+0,-1.5) " by Dose (" f=greek "m" f=simplex "g)"; footnote1 f=simplex " " h=2 move=(+0,+1.5) "1" h=2.5 move=(+0,-1.5) "Concentration after Steady-State " "Dosing (7" f=math "G" f=simplex "1 Days)"; run; quit; The problems are fixed in the below program. A move parameter in the title and footnote create the superscript 1. Also, the Math and Greek fonts are used for the plus-minus sign and micro sign, respectively. The resulting plot is also in Appendix 2. 2 NESUG 16 Posters goptions reset=all device=pdf gsfname=pdfname gunit=pct; filename pdfname "C:\SUBSCRIPT.PDF"; symbol1 i=j v=dot h=1; axis2 label=(f=simplex h=3 a=90 "HCl Concentration") order=0 to 10 by 1 value=(f=simplex h=3); axis1 label=(f=simplex h=3 "H" f=sub "2" f=simplex "0 Concentration") value=(f=simplex h=3) minor=none; proc gplot data=plot; plot y*x / haxis=axis1 vaxis=axis2; title1 f=simplex h=2.5 "Appendix 3 - Subscript Example"; title2 f=simplex h=2.5 "Water Concentration vs Hydrochloric" " Acid Concentration"; footnote; run; quit; Finally, this program shows how fonts can be created. In this case, a subscript two is created. In the previous example the move parameter is used in the title and footnote to create a superscript. That is not supported for use in an axis or a legend, and some form of annotate is often used. By creating a font this can be avoided. This plot is displayed in Appendix 3. data fontdata; input char $ x y segment ptype $; y=y+200; y=y*-1; cards; 2 13 51 1 V 2 13 41 1 V 2 22 24 1 V 2 33 13 1 V 2 51 4 1 V 2 88 4 1 V 2 105 13 1 V 2 110 18 1 V 2 116 23 1 V 2 125 41 1 V 2 125 61 1 V 2 99 105 1 V 2 52 152 1 V 2 5 198 1 V 2 135 198 1 V X 0 -200 1 V X 128 0 1 V ; run; CONCLUSION SAS output and SAS/Graph output can be easily enhanced by using the fonts and special characters discussed in this paper. Further work can include creating additional fonts, exploring the use of TrueType fonts in SAS/Graph and SAS support of Unicode. goptions reset=global gunit=pct border ftext=swissb htitle=6 htext=3; CONTACT INFORMATION Your comments and questions are valued and encouraged. Contact the author at: Doug Lassman PRA International 16400 College Blvd. Lenexa, KS 66219 Phone: 913-438-7696 Fax: 913-599-0344 Email: lassmandoug@praintl.com libname gfont0 'c:\'; proc gfont data=fontdata name=sub height=1in ctext=black showroman romht=.5in resol=2; run; quit; data plot; do x=1 to 10; y=int(ranuni(x)*10+1); output; end; run; TRADEMARK INFORMATION SAS and SAS/GRAPH are registered trademarks of SAS Institute Inc. in the USA and other countries. 3 NESUG 16 Posters NESUG 16 Posters NESUG 16 Posters NESUG 16 Posters NESUG 16 Posters