Enables you to specify a numeric format at run time
Category: Special
PUTN ( source , format .<, w <, d >>)
source
is the SAS expression to which you want to apply the format.
format .
is an expression that contains the numeric format you want to apply to source .
w
specifies a width to apply to the format.
Interaction: If you specify a width here, it overrides any width specification in the format.
d
specifies the number of decimal places to use.
Interaction: If you specify a number here, it overrides any decimal-place specification in the format.
If the PUTN function returns a value to a variable that has not yet been assigned a length, by default the variable is assigned a length of 200.
The PUTC function enables you to specify a character format at run time.
The PROC FORMAT step in this example creates a format, WRITFMT., that formats the variable values 1 and 2 with the name of a SAS date format. The DATA step creates a SAS data set from raw data consisting of a number and a key. After reading a record, the DATA step uses the value of KEY to create a variable, DATEFMT, that contains the value of the appropriate date format. The DATA step also creates a new variable, DATE, whose value is the formatted value of the date. PUTN assigns the value of DATE based on the value of NUMBER and the appropriate format.
proc format; value writfmt 1='date9.' 2='mmddyy10.'; run; data dates; input number key; datefmt=put(key,writfmt.); date=putn(number,datefmt); datalines; 15756 1 14552 2 ;
Functions:
'INPUT Function' on page 592
'INPUTC Function' on page 594
'INPUTN Function' on page 596
'PUT Function' on page 754
'PUTC Function' on page 756