Solved
Contributor
Posts: 23

# One question about DATALINES input

Hi all,

I have an question about reading data from DATALINES, here is the code:

data test;

input test \$40. @@;

datalines;

1---shorter than 80---end

;

data test1;

input test \$40. @@;

datalines;

1---shorter than 80---end

2---longer than 80----------------------------------------------but shorter than 160---end

3---shorter than 80---end

4---shorter than 80---end

;

Data set TEST has 2 records and TEST1 has 14 records. For those 14 records of TEST1, 2 came from the first data line, and 4 from each of the other 3 data lines.

I guess that when reading data from DATALINES, the number "80" should be involved with the the "Length" of  data SAS reads from each line. But I cannot figure out what the exact "RULE" is.

Any help is highly appreciated, thank you very much!

The log:

107  data test;

108      input test \$40. @@;

109  datalines;

NOTE: SAS went to a new line when INPUT statement reached past the end of a line.

NOTE: The data set WORK.TEST has 2 observations and 1 variables.

NOTE: DATA statement used (Total process time):

real time           0.00 seconds

cpu time            0.00 seconds

111  ;

112

113  data test1;

114      input test \$40. @@;

115  datalines;

NOTE: SAS went to a new line when INPUT statement reached past the end of a line.

NOTE: The data set WORK.TEST1 has 14 observations and 1 variables.

NOTE: DATA statement used (Total process time):

real time           0.01 seconds

cpu time            0.00 second

Best regards!

Accepted Solutions
Solution
‎12-01-2012 09:38 PM
Super User
Posts: 8,082

## Re: One question about DATALINES input

Why not just ask SAS to tell you how long the line is?

data _null_;

infile cards length=len ;

input @;

put len= _infile_;

cards;

short line

short line

....+...10....+...20....+...30....+...40....+...50....+...60....+...70....+...80....+...90

short line

run;

len=80 short line

len=80 short line

len=160

....+...10....+...20....+...30....+...40....+...50....+...60....+...70....+...80....+...90

len=160

short line

In general it is a multiple of 80.  (IBM punch cards have 80 postions.) It seems once it bumps up past a multiple of 80 boundary it stays there.

If you are running this in background then the line length of the input stream might be longer.  If your input is from a file on an IBM mainframe or other system where the operating system can set the record length then SAS will most likely understand that.

All Replies
Solution
‎12-01-2012 09:38 PM
Super User
Posts: 8,082

## Re: One question about DATALINES input

Why not just ask SAS to tell you how long the line is?

data _null_;

infile cards length=len ;

input @;

put len= _infile_;

cards;

short line

short line

....+...10....+...20....+...30....+...40....+...50....+...60....+...70....+...80....+...90

short line

run;

len=80 short line

len=80 short line

len=160

....+...10....+...20....+...30....+...40....+...50....+...60....+...70....+...80....+...90

len=160

short line

In general it is a multiple of 80.  (IBM punch cards have 80 postions.) It seems once it bumps up past a multiple of 80 boundary it stays there.

If you are running this in background then the line length of the input stream might be longer.  If your input is from a file on an IBM mainframe or other system where the operating system can set the record length then SAS will most likely understand that.

Contributor
Posts: 23

## Re: One question about DATALINES input

Tom, Thank you very much!

🔒 This topic is solved and locked.