Previous Page | Next Page

SAS Component Language Dictionary

PUTC and PUTN



Return a formatted value, using the specified format
Category: Formatting

Syntax
Details
Examples
Example 1: Using the PUTC Function
Example 2: Using the PUTN Function
See Also

Syntax

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


Details

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.


Examples


Example 1: Using the PUTC Function

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"


Example 2: Using the PUTN Function

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


See Also

INPUTC and INPUTN

Previous Page | Next Page | Top of Page