In your SAS reports, formats control the
way data values are displayed. To make data values more understandable when
displayed in your procedure output, you can use the FORMAT
statement, which associates formats with variables. The FORMAT statement
remains in effect only for the PROC step in which it appears.
Formats affect only the way that the data values appear in output, not the actual data values as they are stored in the SAS data set. |
General form, FORMAT statement:
where
|
You can use a separate FORMAT statement for each variable, or you can format several variables (using the same or different formats) in a single FORMAT statement. |
This FORMAT statement ... | Associates ... |
format date mmddyy6.; |
the format MMDDYY6. with the variable
Date |
format net comma5.0 gross comma8.2; |
the format COMMA5.0 with the variable Net
and the format COMMA8.2 with the variable Gross |
format net gross dollar9.2; |
the format DOLLAR9.2 with both variables, Net
and Gross |
For example, the FORMAT statement below writes values of
the variable Fee using dollar signs, commas, and no decimal
places:
proc print data=clinic.admit; var actlevel fee; where actlevel='HIGH'; format fee dollar4.; run; |
Obs | ActLevel | Fee |
1 | HIGH | $85 |
2 | HIGH | $125 |
6 | HIGH | $125 |
11 | HIGH | $150 |
14 | HIGH | $125 |
18 | HIGH | $85 |
20 | HIGH | $150 |
You can permanently assign a format to a variable in a SAS data set, or you can temporarily specify a format in a PROC step to determine the way that the data values appear in output. |
Copyright © 2002 SAS Institute Inc.,
Cary, NC, USA. All rights reserved.