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!
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.
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.
Tom, Thank you very much!
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.