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::
Excel:
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:
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
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;
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:
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:
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):
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
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.
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)
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.
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
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: