SAS Component Language Dictionary |
Return a formatted value, using the specified format
formatted-val=PUTC(char-val,format);
|
formatted-val=PUTN(num-val,format);
|
-
formatted-val
-
contains the value with the specified format
applied.
Type: Character
-
char-val
-
is the character value to be formatted by
PUTC.
Type: Character
-
num-val
-
is the numeric value to be formatted by
PUTN.
Type: Numeric
-
format
-
is the character format to apply with PUTC
or the numeric format to apply with PUTN. Format
can be an SCL variable or a character literal.
Type: Character
Dot notation cannot be used with the PUTC
or PUTN functions. This restriction is necessary to allow proper parsing of
the char-val and num-val
parameters.
For more information about using a format to return
a value, see the PUT function in
SAS Language Reference: Dictionary.
Format the value that a user enters into the text entry control named VALUE:
MAIN:
value=putc(value,'$QUOTE.');
put value=;
return;
Entering SAS into the field displays "SAS" in the field
and produces the following output:
VALUE="SAS"
Format the variable NETPD using the DOLLAR12.2 format, and store the value
in the variable SALARY.
INIT:
netpd=20000;
put netpd=;
fmt='dollar12.2';
salary=putn(netpd,fmt);
put salary=;
return;
This program produces the following output:
NETPD=20000
SALARY= $20,000.00
INPUTC and INPUTN
Copyright © 2009 by SAS Institute Inc., Cary, NC, USA. All rights reserved.