BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
pchen002
Obsidian | Level 7

Given the following raw data records in DATAFILE.TXT:Given the following raw data records in DATAFILE.TXT:Untitled.png

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!

Untitled.png

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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;

View solution in original post

5 REPLIES 5
RahulG
Barite | Level 11

 

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

Tom
Super User Tom
Super User

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;
pchen002
Obsidian | Level 7
I see!So where did the 'track' goes to?
ballardw
Super User

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.

Ksharp
Super User
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;


sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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