Previous Page | Next Page

SAS Component Language Dictionary

INPUTC and INPUTN



Read a character value using an informat
Category: Formatting

Syntax
Details
Examples
Example 1: Using the INPUTC Function
Example 2: Using the INPUTN Function
Example 3: Using INPUTN with a DATE Value
See Also

Syntax

char-value=INPUTC(char-string,char-informat);
num-value=INPUTN(char-string,num-informat);

char-value

contains char-string with the character informat applied to it.

Type: Character

num-value

contains char-string converted to a numeric value with the numeric informat applied to it.

Type: Numeric

char-string

is the character string to be read.

Type: Character

char-informat

is the character informat to use for reading char-string.

Type: Character

num-informat

is the numeric informat to use for reading char-string.

Type: Numeric


Details

INPUTC and INPUTN both read a character value. However, INPUTC applies a character informat and returns a character value, and INPUTN applies a numeric informat and returns a numeric value. These functions are similar to the INPUT function in the DATA step.

Note:   Dot notation cannot be used with the INPUTC or INPUTN functions. This restriction is necessary to allow proper parsing of the char-informat and num-informat parameters.  [cautionend]

For more information about using an informat to read a value, see the INPUT function for the DATA step in SAS Language Reference: Dictionary.


Examples


Example 1: Using the INPUTC Function

Read the character variable NAME, using the $UPCASE3. informat:

name='sas';
cval=inputc(name,'$upcase3.');
put cval=;

This program produces the following output:

cval=SAS


Example 2: Using the INPUTN Function

Read the character variable AMOUNT, containing the value $20,000.00, into the numeric variable SALARY, using the COMMA10.2 informat:

amount='$20,000.00';
informat='comma10.2';
salary=inputn(amount,informat);
put salary=;

This program produces the following output:

salary=20000


Example 3: Using INPUTN with a DATE Value

Read the value in DATE and apply the JULIAN8. informat:

date='90091';
ndate=inputn(date,'julian8.');
put ndate=;

This program produces the following output:

ndate=11048


See Also

PUTC and PUTN

Previous Page | Next Page | Top of Page