Informats determine
how raw data values are read and stored. Formats determine how variable
values are printed. For simplicity, this section uses the terminology
the informat converts and the format prints.
Informats and formats
tell SAS the data's type (character or numeric) and form (such as
how many bytes it occupies; decimal placement for numbers; how to
handle leading, trailing, or embedded blanks and zeros; and so on).
SAS provides informats and formats for reading and writing variables.
For a thorough description of informats and formats that SAS provides,
see
SAS Formats and Informats: Reference.
With informats, you
can do the following:
-
Convert a number to a character
string (for example, convert 1 to
YES
).
-
Convert a character string to a
different character string (for example, convert
'YES'
to
'OUI'
).
-
Convert a character string to a
number (for example, convert
YES
to
1).
-
Convert a number to another number
(for example, convert 0–9 to 1, 10–100 to 2, and so
on).
Note: User-defined informats read-only
character data. They can convert character values into real numeric
values, but they cannot convert real numbers into characters.
With formats, you can
do the following:
-
Print numeric values as character
values (for example, print 1 as
MALE
and
2 as
FEMALE
).
-
Print one character string as a
different character string (for example, print
YES
as
OUI
).
-
Print numeric values using a template
(for example, print 9458763450 as
945-876-3450
).