SAS Data Statement - Input Keyword

Overview

The input keyword identifies the variables you want to use in your SAS program, the type of value it contains (numeric or alphanumeric), and the fields within a case that contain the value.

Through the use of field descriptor's we can specify a wide range of fields and potentially read any data file into SAS.

Basic rules for the input keyword

This section is taken from the book The SAS System for Elementary Statistical Analysis, Pg. 38-40.

While SAS can handle extremely complex files we are usually lucky in that most data files are consistently formatted and can be read easily. Follow the steps below when creating the input statement:

  1. Begin with the word input.
  2. Choose a name for the first variable (remember eight character limit and must start with a letter).
  3. Determine whether the values for this variable are numeric or alphanumeric. If any of the cases use alphanumeric values then you must define this as a character variable, otherwise it should be a numeric variable. If it is a character variable place a dollar sign after the name.
  4. Enter the starting column number for this variable, a hyphen, and the ending column number for that column.
  5. Repeat steps 2 through 4 for each variable in program.
  6. When completed, end the input statement with a semicolon ";".

Guidelines for entering data

When possible, it is advisable to follow these guidelines when creating data sets.
  1. Create a unique case-id for each case. With this, if you find errors in your data your can easily determine the case where this occured.
  2. Determine the maximum size of each variable in your data file and use that size when entering the value. For example in a value is age and varies from 1 through 100, you should allocate three columns for that value.
  3. Leave a blank space between values in your data file. By doing this you can easily see if a field is out of alignment when you view the file.

For more information, please consult the BASE SAS manual.


Author - Jack Suess
UMBC University Computing Services
Created - 1/15/96