Language Reference


BYTE Function

BYTE (matrix);

The BYTE function returns values in a computer’s character set. The input to the function is a numeric matrix, each element of which specifies the position of a character in the computer’s character set. These numeric elements should generally be in the range 0 to 255. The BYTE function returns a character matrix with the same shape as the numeric argument.

For example, in the ASCII character set, the following two statements are equivalent:

a1 = byte(47);
a2 = "/";       /* the slash character */
print a1 a2;

Figure 24.64: Specifying the Slash Character

a1 a2
/ /



The lowercase English letters can be generated with the following statement, shown in Figure 24.65:

y = byte(97:122);    /* or use "a":"z" */
print y;

Figure 24.65: Lowercase English Letters

y
a b c d e f g h i j k l m n o p q r s t u v w x y z



The BYTE function simplifies the use of special characters and control sequences that cannot be entered directly into SAS/IML programs by using the keyboard. Consult the character set tables for your computer to determine the printable and control characters that are available and their ordinal positions.