Previous Page | Next Page

Functions and CALL Routines

INPUTC Function



Enables you to specify a character informat at run time.
Category: Special

Syntax
Arguments
Details
Comparisons
Examples
Example 1: Specifying Character Informats
See Also

Syntax

INPUTC(source, informat<,w>)


Arguments

source

specifies a character constant, variable, or expression to which you want to apply the informat.

informat

is a character constant, variable, or expression that contains the character informat you want to apply to source.

w

is a numeric constant, variable, or expression that specifies a width to apply to the informat.

Interaction: If you specify a width here, it overrides any width specification in the informat.

Details

If the INPUTC function returns a value to a variable that has not yet been assigned a length, by default the variable length is determined by the length of the first argument.


Comparisons

The INPUTN function enables you to specify a numeric informat at run time. Using the INPUT function is faster because you specify the informat at compile time.


Examples


Example 1: Specifying Character Informats

The PROC FORMAT step in this example creates a format, TYPEFMT., that formats the variable values 1, 2, and 3 with the name of one of the three informats that this step also creates. The informats store responses of "positive," "negative," and "neutral" as different words, depending on the type of question. After PROC FORMAT creates the format and informats, the DATA step creates a SAS data set from raw data consisting of a number identifying the type of question and a response. After reading a record, the DATA step uses the value of TYPE to create a variable, RESPINF, that contains the value of the appropriate informat for the current type of question. The DATA step also creates another variable, WORD, whose value is the appropriate word for a response. The INPUTC function assigns the value of WORD based on the type of question and the appropriate informat.

   proc format;
      value typefmt 1='$groupx' 
                    2='$groupy'
                    3='$groupz';
      invalue $groupx 'positive'='agree'
                      'negative'='disagree'
                      'neutral'='notsure';
      invalue $groupy 'positive'='accept'
                      'negative'='reject'
                      'neutral'='possible';

      invalue $groupz 'positive'='pass'
                      'negative'='fail'
                      'neutral'='retest';
   run;

   data answers;
      input type response $;
      respinformat = put(type, typefmt.);
      word = inputc(response, respinformat);
      datalines;
   1 positive
   1 negative
   1 neutral
   2 positive
   2 negative
   2 neutral
   3 positive
   3 negative
   3 neutral
   ;

The value of WORD for the first observation is agree . The value of WORD for the last observation is retest .


See Also

Functions:

INPUT Function

INPUTN Function

PUT Function

PUTC Function

PUTN Function

Previous Page | Next Page | Top of Page