DATA Step, Macro, Functions and more

Creating subscripts and superscripts

Occasional Contributor
Posts: 5

Creating subscripts and superscripts

I have a table win which one of the cells has an entry (mg/L as SO4). How do I express the 4 in the cell entry as a subscript with the PRC REPORT Statement. See attached file. I tried the code below but it does not get me the right information

Libname tested 'C:\Users\Test_LIBR';
ods pdf file="&tested\Filename.pdf";
ods escapechar="^";
DATA test2;
SET test;
format United $35.;Informat United $35.;
Format Position $4.;
Position = Index(Units,'4)');
If Position gt 0 Then United = Trim(Substr(Units,1,Position-1)||'^{Sub 4}')||')';
Else United = Units;
Proc report data = work.test2;
Column Determinand_Grouping Determinand United units;
define Determinand_Grouping / group order = data noprint;
Define Determinand / style(column)=[fontstyle=italic];
Define Units / style(column)=[fontstyle=italic];
ods _all_ close;


Super User
Super User
Posts: 9,599

Re: Creating subscripts and superscripts

[ Edited ]

What "does not work"? You have posted code which creates a PDF file, and yet your example output is Excel? The escapechar and sub works fine using PDF destination output (note I can only paste text at the mo):


ods pdf file="s:\temp\rob\test.pdf";

data temp;

  a="abc ^{sub 4}";



ods escapechar="^";


proc report data=temp nowd;

 columns a;


ods pdf close;


Works fine. Also please note how formatting of the code is very important to reading, mixed case and no indetation makes reading code so much harder.

Ask a Question
Discussion stats
  • 1 reply
  • 2 in conversation