As the first step in the decommissioning of sasCommunity.org the site has been converted to read-only mode.


Here are some tips for How to share your SAS knowledge with your professional network.


DATALINES statement

From sasCommunity
Jump to: navigation, search

The DATALINES statement introduces lines of data in a DATA Step. There are two alternative statement keywords that can be used for this statement; the CARDS statement and the LINES statement.

Syntax

DATALINES ;

or

CARDS ;

or

LINES ;

followed by

<any number of lines of data>
;
RUN statement ;

Usage

The DATALINES statement preceeds any lines of data that are going to be read into the DATA step. The lines of data that immediately follow this statement end when the first semicolon is encountered. If the data contains semicolons then the DATALINES4 statement needs to be used instead.

The DATALINES statement must be used at the end of a DATA Step after all the other statements in the data step but before the lines of data.

The terminating semicolon should be the first character on a new line and can be followed by the RUN statement.

To read the lines of data that follow the DATALINES statement the DATA step must also contain at least one INPUT statement to read the data. An INFILE statement that associates the datalines with an infile name can also be used if the data is delimited or other infile options need to be used to read the data.

Example

DATA lines_of_data;
     INPUT a_number ;
     DATALINES ;
1
23
4
567
;
RUN;

Will produce the dataset LINES_OF_DATA containing

A_NUMBER
       1
      23
       4
     567

See also