Specifies that lines of data follow the statement.
| Valid in: | DATA step |
|---|---|
| Category: | File-Handling |
| Type: | Declarative |
| Alias: | CARDS, LINES |
| Restriction: | This statement is not supported in a DATA step that runs in CAS. |
| See: | Data lines cannot contain semicolons. Use the DATALINES4 Statement when your data contains semicolons. |
Table of Contents
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.
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.
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.
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 that you need. For more information, see Reading In-Stream Data with Options.
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
;
This example takes advantage of options that are 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
;