(111) 123-1234
. You can
use the PICTURE statement to create a template for printing numbers.
General form, PROC FORMAT
with the PICTURE statement:
PROC FORMAT;
PICTURE format-name
value-or-range='picture';
RUN;
format-name
is the name of the
format that you are creating.
value-or-range
is the individual value
or range of values that you want to label.
picture
specifies a template
for formatting values of numeric variables. The template is a sequence
of characters enclosed in quotation marks. The maximum length for
a picture is 40 characters.
|
Picture Definition
|
Data Values
|
Formatted Values
|
---|---|---|
picture month 1-12='99'; |
1
12
|
01
12
|
picture month 1-12='00'; |
1
12
|
1
12
|
proc format; picture rainamt 0-2='9.99 slight' 2<-4='9.99 moderate' 4<-<10='9.99 heavy' other='999 check value'; run; data rain; input Amount; datalines; 4 3.9 20 .5 6 ; proc print data=rain; format amount rainamt.; run;
General form, PICTURE
statement with the DATATYPE= option:
PICTURE format-name
value-or-range,
'picture' (DATATYPE=SAS-date-value-type);
format-name
is the name of the
format that you are creating.
value-or-range
is the individual value
or range of values that you want to label.
picture
specifies
a template with directives for formatting numeric values.
SAS-date-value-type
is either DATE, TIME,
or DATETIME.
|
Directive
|
Result
|
---|---|
%a
|
abbreviated weekday
name
|
%A
|
full weekday name
|
%b
|
abbreviated month name
|
%B
|
full month name
|
%d
|
day of the month as
a number 1-31, with no leading zero
|
%H
|
24-hour clock as a number
0-23, with no leading zero
|
%I
|
12-hour clock as a number
1-12, with no leading zero
|
%j
|
day of the year as a
number 1-366, with no leading zero
|
%m
|
month as a number 1-12,
with no leading zero
|
%M
|
minute as a decimal
number 0-59, with no leading zero
|
%p
|
AM or PM
|
%S
|
second as a number 0-59,
with no leading zero
|
%U
|
week number of the year
(Sunday is the first day of the week) as a number 0-53, with no leading
zero
|
%w
|
weekday as a number
(1=Sunday, to 7)
|
%y
|
year without century
as a number 0-99, with no leading zero
|
%Y
|
year with century as
a number
|
25-JAN2000
). This format requires
spaces for 10 characters.
proc format; picture mydate low-high='%0d-%b%Y ' (datatype=date); run; proc print data=sasuser.empdata (keep=division hireDate lastName obs=5); format hiredate mydate.; run;