Syntax, FORMAT statement:
FORMAT variable(s)
format-name;
Tip:The FORMAT statement applies
only to the PROC step in which it appears.
|
FORMAT Statement
|
Description
|
Example
|
---|---|---|
format date mmddyy8.; |
associates the format
MMDDYY8. with the variable Date
|
06/05/03
|
format net comma5.0 gross comma8.2; |
associates the format
COMMA5.0 with the variable Net and the format COMMA8.2 with the variable
Gross
|
1,234
5,678.90
|
format net gross dollar9.2; |
associates the format
DOLLAR9.2 with both variables, Net, and Gross
|
$1,234.00
$5,678.90
|
proc print data=clinic.admit;
var actlevel fee;
where actlevel='HIGH';
format fee dollar4.;
run;
Format
|
Description
|
Example
|
---|---|---|
COMMAw.d
|
specifies values that
contain commas and decimal places
|
comma8.2
|
DOLLARw.d
|
specifies values that
contain dollar signs, commas, and decimal places
|
dollar6.2
|
MMDDYYw.
|
specifies values as
date values of the form 09/12/97 (MMDDYY8.) or 09/12/1997 (MMDDYY10.)
|
mmddyy10.
|
w.
|
specifies values that
are rounded to the nearest integer in w spaces
|
7.
|
w.d
|
specifies values that
are rounded to d decimal places
in w spaces
|
8.2
|
$w.
|
specifies values as
character values in w spaces
|
$12.
|
DATEw.
|
specifies values as
date values of the form 16OCT99 (DATE7.) or 16OCT1999 (DATE9.)
|
date9.
|
Stored Value
|
Format
|
Displayed Value
|
---|---|---|
38245.3975
|
COMMA12.2
|
38,245.40
|
38245.3975
|
12.2
|
38245.40
|
38245.3975
|
DOLLAR12.2
|
$38,245.40
|
38245.3975
|
DOLLAR9.2
|
$38245.40
|
38245.3975
|
DOLLAR8.2
|
38245.40
|
0
|
MMDDYY8.
|
01/01/60
|
0
|
MMDDYY10.
|
01/01/1960
|
0
|
DATE7.
|
01JAN60
|
0
|
DATE9.
|
01JAN1960
|