BookmarkSubscribeRSS Feed
_Manhattan
Quartz | Level 8

Hello,

I would like to add some superscript to my PDF document. I have found some information on how to do this, but my output looks a bit off.

I have imported an excel file (see screenshot below) to test how the outcome looks. I would like the outcome to look like in the first row "HERE". You can see that the superscript "1" is directly matched to the text. I have noticed the longer the string is the wider the gap between the content and the text gets. Do you have an idea how to stick the superscript to the text like in the first row?

 

proc import
  datafile="yourpath\superscript_test.xlsx"
  out=supers
  dbms=excel
  replace;
run;

options papersize=a4 orientation=portrait nobyline nodate leftmargin=1.5cm rightmargin=2.5cm bottommargin=0.5cm topmargin=2cm nonumber;
ods pdf file="yourpath\testSUPER.pdf";
proc report data=supers;
column test;
define test / "test" display style(column)=[cellwidth=15cm fontfamily=calibri fontsize=10pt];
run;
ods pdf close;

Output PDF::

_Manhattan_1-1721655052030.png

Excel:

_Manhattan_2-1721655117645.png

 

 

 

 

 

 

 

8 REPLIES 8
Cynthia_sas
SAS Super FREQ

Hi, I'm not sure how/where the Excel fits in here. When I run this test, the ODS PDF super and subscripts look fine to me:

Cynthia_sas_0-1721670389994.png

As you can see, it is possible with ODS to use either the ESCAPECHAR SUPER/SUB or UNICODE functions to insert superscript or subscripts into text. However, key to this working is to be sure you have an ODS ESCAPECHAR statement so that ODS knows which character to use for the ESCAPECHAR string.

Cynthia

_Manhattan
Quartz | Level 8

Hi @Cynthia_sas,

I have used your code to troubleshoot. The problem seems to be the definition of a fontfamily. If I use the following code the problem occurs. But without the fontfamily statement it works as intended. Unfortunately, I need a font different to the default one. Arial would be fine as well, but the problem occurs there too.

data testsuper;
	length tline $200;
	infile datalines dlm =",";
	input ord tline $;
	datalines;
	1, Here^{super 1} There^{super 2} and what about here^{super 3}
	2, Twas^{super 4} and what about now^{super 5}
	3, No other context given but this^{super 6}
	;
run;

ods escapechar="^";
options papersize=a4 orientation=portrait nobyline nodate leftmargin=1.5cm rightmargin=2.5cm bottommargin=0.5cm topmargin=2cm nonumber;
ods pdf file="yourpath\testSUPER.pdf";
proc report data=testsuper;
column ord tline;
define ord / order;
define tline / "TestLine" display style(column)=[cellwidth=15cm fontfamily=calibri fontsize=10pt];
run;
ods pdf close;
Cynthia_sas
SAS Super FREQ

Hi:

  Interesting. I thought Calibri was a Microsoft-specific font only available with Office. As a test, when I try to use either calibri or Calibri, I get some version of this message:

Cynthia_sas_0-1721757439393.png

So this implies to me that 1) either Calibri needs to be registered with SAS (but that is still no guarantee that PDF will use a Microsoft font) or 2) you need to find the unicode equivalent of Calibri that Adobe respects. As an example, if I wanted to use the Arial font in a PDF document, I would need to specify the font as "Arial Unicode MS" as shown below:

Cynthia_sas_1-1721757559906.png

  But when I tried "Calibri Unicode MS" that is also not a valid font name. So my suspicion is that Calibri, like Arial is a Windows/Microsoft-defined font, which means that you probably have to register it with SAS and also, if you are going to be creating the output on a Unix/Linux server, you may have to copy the font over to the server so it can be used. Or you may want to just use Helvetica which is very similar to Calibri and Arial. Or, instead of Calibri or Arial use Albany AMT, which is shipped with SAS. Here's a comparison of the 2 Microsoft fonts with Albany (shown in Word):

Cynthia_sas_2-1721758670788.png

 

  My recommendation is that you work with SAS Tech Support on this since if Calibri is a Microsoft specific font, it may not work for PDF.

Cynthia

ballardw
Super User

FWIW, I ran your code minus the OPTIONS statement and it generated the superscripts and document properties show Calibri as one of the fonts. I also checked my SAS fontlist and Calibri does appear there. I suspect that I ran Proc FONTREG a long time ago for some font and loaded many of the MS fonts. Changing Calibri for Arial and I still get the superscripts and the Arial font appears in the document properties.

 

 

_Manhattan
Quartz | Level 8

I have run the following code

proc registry listhelp startat='ods\fonts'; run;

and noticed that I do not have calibri as a font installed in SAS.

However, if I try to add Fonts with the following code

proc fontreg
  mode=add
  msglevel=normal
  usesashelp
;
  truetype "C:\yourpath\Microsoft\Windows\Fonts";
run;

I receive the ERROR:  User does not have appropriate authorization level for file SASHELP.REGSTRY.ITEMSTOR

 

Do you know any work around to resolve this issue? Alternatively, I will consider using Albany MT (thanks @Cynthia_sas for the short overview of the comparison of the fonts)

ballardw
Super User

Sounds like you do not have write privileges in the SASHELP library.

 

Remove the USESASHELP and try that instead. This will update the registry in the SASUSER library.

_Manhattan
Quartz | Level 8

I just realised that I did not use the right file path. With the following code I got the Log down below

proc fontreg
  mode=all
  msglevel=verbose
;
  fontfile "C:\Windows\Fonts\calibri.ttf";
run;
 WARNING: The "Calibri" font family being processed supports more character encodings than the 
          existing family of the same name in the SAS registry. Only the encodings currently 
          supported by the family in the SAS registry will be available. 
 
 NOTE: The font "Calibri" (Style: Regular, Weight: Normal) has been replaced in the SAS Registry 
       at [CORE\PRINTING\FREETYPE\FONTS\<ttf> Calibri]. Because it is a TRUETYPE font, it can be 
       referenced as "Calibri" or "<ttf> Calibri" in SAS. The font resides in file 
       "C:\Windows\Fonts\calibri.ttf". 

I read that as "it worked". Unfortunately, my output still looks the same

_Manhattan_0-1721895868575.png

 

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 8 replies
  • 1106 views
  • 0 likes
  • 3 in conversation