Formatting Variable Values |
Assigning Formats to
Variables |
Temporarily Formatting Values
As you know, you use the FORMAT statement to associate a specific format
with a variable. For example, this FORMAT statement associates the
DOLLARw.d format with the variable
format fee dollar9.2;
Remember that multiple formats and variables can be associated in a single
FORMAT format supplies dollar6.2 fee dollar9.2; . . . or in multiple FORMAT statements . . . format supplies dollar6.2; format fee dollar9.2; . . . and you can associate the same format with several variables in a statement. format supplies pharmacycost dollar6.2; Finally, you can add FORMAT statements to the PRINT procedure to enhance the data values in a report. proc print data=perm.employee; format salary dollar10.2; run; |
Obs | LastName | Department | Salary |
1 | Henderson | B101 | $23,987.45 |
2 | Markham | B101 | $26,234.09 |
3 | Turner | B102 | $24,678.23 |
However, when you place a FORMAT statement in a procedure step, the formats
that are associated with the variables remain in effect only for that particular
step. Notice that the format specified in the first PROC PRINT step does
not affect the appearance of the values for
Salary in the second step.
1. proc print data=perm.employee; format salary dollar10.2; run; |
Obs | LastName | Department | Salary |
1 | Henderson | B101 | $23,987.45 |
2 | Markham | B101 | $26,234.09 |
2. proc print data=perm.employee; var department lastname salary; run; |
Obs | LastName | Department | Salary |
1 | Henderson | B101 | 23987.45 |
2 | Markham | B101 | 26234.09 |
Copyright © 2002 SAS Institute Inc.,
Cary, NC, USA. All rights reserved.