Formatting Variable Values |
Assigning Formats to
Variables |
Permanently Formatting Values
Now that you have the FORMAT statement written, how do you permanently associate the formats with their respective variables? You place the FORMAT statement in the DATA step. data perm.aprbills; infile aprdata; input LastName $8. @10 DateIn mmddyy8. +1 DateOut mmddyy8. +1 RoomRate 6. @35 EquipCost 6.; Days=dateout-datein+1; RoomCharge=days*roomrate; Total=roomcharge+equipcost; format datein dateout date9. roomrate 6.2 roomcharge comma8.2 total dollar9.2; run; When the DATA step is processed, the formats are permanently associated with their respective variables. To view the formats associated with variables in a data set, select the data set in the Explorer window, then display properties for columns. |
Column Properties for SAS Data Set Perm.Aprbills
|
Each time a procedure (such as PROC PRINT) accesses the data set, the
output displays the formatted values.
proc print data=perm.aprbills; run; |
Obs | LastName | DateIn | DateOut | RoomRate | EquipCost | Days | RoomCharge | Total |
1 | Akron | 05APR1990 | 09APR1990 | 175.00 | 298.45 | 4 | 700.00 | $998.45 |
2 | Brown | 12APR1990 | 01MAY1990 | 125.00 | 326.78 | 19 | 2,375.00 | $2,701.78 |
3 | Carnes | 27APR1990 | 29APR1990 | 125.00 | 174.24 | 2 | 250.00 | $424.24 |
4 | Denison | 11APR1990 | 12APR1990 | 175.00 | 87.41 | 1 | 175.00 | $262.41 |
5 | Fields | 15APR1990 | 22APR1990 | 175.00 | 378.96 | 7 | 1,225.00 | $1,603.96 |
6 | Jaminson | 16APR1990 | 23APR1990 | 125.00 | 346.28 | 7 | 875.00 | $1,221.28 |
Copyright © 2002 SAS Institute Inc.,
Cary, NC, USA. All rights reserved.