SAS OnlineTutor HomeFAQ PageSuggested Learning PathsContents+Searchback||next

Formatting Variable Values
Assigning Formats to Variables


Permanently Formatting Values

Let's see how you can permanently associate formats with variables. If you use PROC PRINT to display the data set Perm.Aprbills, the ouput looks like this:

     proc print data=perm.aprbills;
     run;

Obs LastName DateIn DateOut RoomRate EquipCost Days RoomCharge Total
1 Akron 11052 11056 175 298.45 4 700 998.45
2 Brown 11059 11077 125 326.78 19 2375 2701.78
3 Carnes 11074 11076 125 174.24 2 250 424.24
4 Denison 11058 11059 175 87.41 1 175 262.41


Suppose you want to display these variables with the following formats:
     DateIn, DateOut    DATEw.
     RoomRate           w.d
     RoomCharge            COMMAw.d
     Total              DOLLARw.d

You might not be familiar with the DATEw. and w.d formats, so let's discuss those first. The DATEw. format displays variable values in the form ddmmmyy or ddmmmyyyy, where

  • dd is an integer from 01 to 31, which represents the day
  • mmm is the first three letters of the month's name
  • yy or yyyy is the integer that represents the year

For example:

     date7.    0   5   S   E   P   0   1
               1   2   3   4   5   6   7

     date9.    0   5   S   E   P   2   0   0   1
               1   2   3   4   5   6   7   8   9

The w.d format displays standard numeric values. The w value specifies the total width that is needed to display the values in output. The optional d value displays the number of decimal places. For example:

     7.      3   5   6   8   0   1   1
             1   2   3   4   5   6   7

     10.2    3   5   6   8   0   1   1   .   0   0
             1   2   3   4   5   6   7   8   9  10


back||next


Copyright © 2002 SAS Institute Inc., Cary, NC, USA. All rights reserved.

Terms of Use & Legal Information | Privacy Statement