Solved
Contributor
Posts: 31

# Data step input

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!

Accepted Solutions
Solution
‎10-05-2017 03:42 AM
Super User
Posts: 8,289

## Re: Data step input

[ Edited ]

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;``````

All Replies
Super Contributor
Posts: 271

## Re: Data step input

[ Edited ]

Use Truncover option in infile statement to  read the thrid line as record number 3

Solution
‎10-05-2017 03:42 AM
Super User
Posts: 8,289

## Re: Data step input

[ Edited ]

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;``````
Contributor
Posts: 31

## Re: Data step input

I see!So where did the 'track' goes to?
Super User
Posts: 13,947

## Re: Data step input

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.

Super User
Posts: 10,860

## Re: Data step input

```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;

```
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
• 5 replies
• 178 views
• 1 like
• 5 in conversation