DATALINES Statement


Indicates that data lines follow

Valid: in a DATA step

Category: File-handling

Type: Declarative

Aliases: CARDS, LINES

Restriction: Data lines cannot contain semicolons. Use 'DATALINES4 Statement' on page 1132 when your data contain semicolons.

Syntax

DATALINES ;

Without Arguments

Use the DATALINES statement with an INPUT statement to read data that you enter directly in the program, rather than data stored in an external file.

Details

Using the DATALINES Statement The DATALINES statement is the last statement in the DATA step and immediately precedes the first data line. Use a null statement (a single semicolon) to indicate the end of the input data.

You can use only one DATALINES statement in a DATA step. Use separate DATA steps to enter multiple sets of data.

Reading Long Data Lines SAS handles data line length with the CARDIMAGE system option. If you use CARDIMAGE, SAS processes data lines exactly like 80-byte punched card images padded with blanks. If you use NOCARDIMAGE, SAS processes data lines longer than 80 columns in their entirety. Refer to 'CARDIMAGE System Option' on page 1487 for details.

Using Input Options with In-stream Data The DATALINES statement does not provide input options for reading data. However, you can access some options by using the DATALINES statement in conjunction with an INFILE statement. Specify DATALINES in the INFILE statement to indicate the source of the data and then use the options you need. See Example 2 on page 1132.

Comparisons

  • Use the DATALINES statement whenever data do not contain semicolons. If your data contain semicolons, use the DATALINES4 statement.

  • The following SAS statements also read data or point to a location where data are stored:

    • The INFILE statement points to raw data lines stored in another file. The INPUT statement reads those data lines.

    • The %INCLUDE statement brings SAS program statements or data lines stored in SAS files or external files into the current program.

    • The SET, MERGE, MODIFY, and UPDATE statements read observations from existing SAS data sets.

Examples

Example 1: Using the DATALINES Statement

In this example, SAS reads a data line and assigns values to two character variables , NAME and DEPT, for each observation in the DATA step:

 data person;     input name $ dept $;     datalines;  John Sales  Mary Acctng  ; 

Example 2: Reading In-stream Data with Options

This example takes advantage of options available with the INFILE statement to read in-stream data lines. With the DELIMITER = option, you can use list input to read data values that are delimited by commas instead of blanks.

 data person;     infile datalines delimiter=',';     input name $ dept $;     datalines;  John,Sales  Mary,Acctng  ; 

See Also

Statements:

  • 'DATALINES4 Statement' on page 1132

  • 'INFILE Statement' on page 1222

System Option:

  • 'CARDIMAGE System Option' on page 1487




SAS 9.1 Language Reference Dictionary, Volumes 1, 2 and 3
SAS 9.1 Language Reference Dictionary, Volumes 1, 2 and 3
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 704

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net