Chapter Contents

Previous

Next
PUTN

PUTN



Enables you to specify a numeric format at run time

Category: Special


Syntax
Arguments
Comparisons
Examples
Example 1: Specifying a Numeric Format
See Also

Syntax

PUTN(source, format.<,w<,d>>)

Arguments

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.


Comparisons

The PUTC function enables you to specify a character format at run time.


Examples

Example 1: Specifying a Numeric Format

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
;

See Also

Functions:

INPUT
INPUTC
INPUTN
PUT
PUTC


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.