Given the following raw data records in DATAFILE.TXT:Given the following raw data records in DATAFILE.TXT:
Given the above raw data records in DATAFILE.TXT:
The following is the ouput of the data. Why is 'track' being cut off?Is it because there is no @ at input step to suppress it from reading the next data into same line?Thanks!
No.
It is because you did not use @@ at the end of the INPUT statement to hold the line over to the next iteration of the data step.
Using only a single trailing @ will only hold the line for another INPUT statement on the same iteration of the data step.
Test it yourself.
data test1;
length v1-v3 $8 ;
input v1-v3 ;
cards;
1 2 3 4
5 6
7 8 9
10 11 12
;
proc print; run;
data test2;
length v1-v3 $8 ;
input v1-v3 @ ;
cards;
1 2 3 4
5 6
7 8 9
10 11 12
;
proc print; run;
data test3;
length v1-v3 $8 ;
input v1-v3 @@ ;
cards;
1 2 3 4
5 6
7 8 9
10 11 12
;
proc print; run;
Use Truncover option in infile statement to read the thrid line as record number 3
No.
It is because you did not use @@ at the end of the INPUT statement to hold the line over to the next iteration of the data step.
Using only a single trailing @ will only hold the line for another INPUT statement on the same iteration of the data step.
Test it yourself.
data test1;
length v1-v3 $8 ;
input v1-v3 ;
cards;
1 2 3 4
5 6
7 8 9
10 11 12
;
proc print; run;
data test2;
length v1-v3 $8 ;
input v1-v3 @ ;
cards;
1 2 3 4
5 6
7 8 9
10 11 12
;
proc print; run;
data test3;
length v1-v3 $8 ;
input v1-v3 @@ ;
cards;
1 2 3 4
5 6
7 8 9
10 11 12
;
proc print; run;
Which version of SAS are you using and do have the online help installed?
There are lots of examples in the online help that really should have been installed on reading external files. If I place the cursor on the word "input" in a data step and press the F1 key the online help opens with a selection window with a number of options for the INPUT statement. You should look over all of them and look at the actual examples in each section. Then when you don't understand why something doesn't work after going through the examples ask.
We're willing to help but not actually interested in being a replacement for the basic online help system.
The default usage of INFILE is flowover ,which is going to jump into next row if there is no more data to be read. infile ....... flowover; therefore, you need truncover to make thing right. infile ....... truncover;
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.