There may be times when you need a specific character used in your outputs, for example superscripts or trade mark symbols in a footnote, but cannot see these directly on your keyboard. These characters and many more are all accessible for use in your SAS programs.
This table shows some of the special characters available to use, along with their corresponding byte number in SAS and a description.
This table shows some of the special characters available to use, along with their corresponding byte number in SAS and a description.
Byte(i)
|
Symbol
|
Description
|
153
|
™
|
Trademark sign
|
169
|
©
|
Copyright sign
|
170
|
ยช
|
Superscript a
|
174
|
®
|
Registered trademark sign
|
176
|
°
|
Degree symbol
|
177
|
±
|
Plus or minus sign
|
178
|
²
|
Superscript 2 / squared
|
179
|
³
|
Superscript 3 / cubed
|
185
|
¹
|
Superscript 1
|
188
|
¼
|
One quarter
|
189
|
½
|
Half
|
190
|
¾
|
Three quarters
|
247
|
÷
|
Division sign
|
The full list of characters can be seen by running the following code. This will create a dataset with a variable containing each special character and a variable with each respective byte number in SAS.
data check;
do i=1 to 255;
sq=byte(i);
output;
end;
run;
Once you know which character you want in your program, then you can use %let to create a macro variable of it. For example the following code will create a macro variable for the superscript a symbol:
%let supa=%sysfunc(byte(170));
If you want to check this has worked properly, then use %put to write the value of this macro variable to the log:
%put &supa;
The macro variable can then be inserted into your program. For example the following is standard proc report code for creating a table, but using this macro variable to create a superscript value in the footnote. The highlighted code shows where the macro variable is used.
proc report data=final nowd headline headskip split=' | ' ps=23formchar(2)='_';
column ('__' pdcdl col1 ord1 ord2);
define pdcdl / left ' ' width=60;
define col1 / center 'DrugA|6 mg SC';
define ord1 / order noprint;
define ord2 / order noprint;
title 'Table 14-1.3 Summary of Important Protocol Deviations';
compute after _page_;
line @13 72*"_";
line @2 ' ';
line @14 "&supa Other than Treatment Compliance/Test Article Administration";
line @14 'Note: Deviation categories are not mutually exclusive';
endcomp;
break after ord1 / skip;
run;
This will create the following output. The highlighted part shows what the footnote looks like from inserting the special character into it.
As you can see in the example, it is a simple process to find out the byte number of the desired special character and then use it in your program.
No comments:
Post a Comment