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

This is what i have

 

DATA B_1;
INFILE DATALINES ;
input x y  @@;
datalines;
1 2 3 4 4 5  5 4  
;

 The row with the number 1 2 3 4 4 5  5 4 .......................  is very large . i just put a small numbers to make it easy.

 

This is what i want

XY
12
34
45
 5
4 
1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

I specified the delimiter as well, but it has trouble determining the end of the data set then. For some reason it thinks it has 37 records now...

 

DATA B_1;
INFILE DATALINES dlm=' ' dsd;
input x y  @@;
datalines;
1 2 3 4 4 5  5 4
;
run;

 Log:

 

16999 DATA B_1;
17000 INFILE DATALINES dlm=' ' dsd;
17001 input x y @@;
17002 datalines;

NOTE: LOST CARD.
RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
17004 ;
x=. y=. _ERROR_=1 _N_=37
NOTE: SAS went to a new line when INPUT statement reached past the end of a line.
NOTE: The data set WORK.B_1 has 36 observations and 2 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds


17004 ;
17005 run;

 

 

 

View solution in original post

10 REPLIES 10
Reeza
Super User

Try adding the DSD option?

 

INFILE DATALINES  DSD;

@athapa1183 wrote:

This is what i have

 

DATA B_1;
INFILE DATALINES ;
@input x y  @@;
datalines;
1 2 3 4 4 5  5 4  
;

 The row with the number 1 2 3 4 4 5  5 4 .......................  is very large . i just put a small numbers to make it easy.

 

This is what i want

X Y
1 2
3 4
4 5
  5
4  

 

athapa1183
Obsidian | Level 7

 

DSD does not help.

 

 

417 DATA B_1;
418 INFILE DATALINES DSD;
419 input x y @@;
420 datalines;

NOTE: Invalid data for x in line 421 1-16.
NOTE: LOST CARD.
RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+--
422 ;
NOTE: Invalid data errors for file CARDS occurred outside the printed range.
NOTE: Increase available buffer lines with the INFILE n= option.
x=. y=. _ERROR_=1 _N_=1
NOTE: SAS went to a new line when INPUT statement reached past the end of a line.
NOTE: The data set WORK.B_1 has 0 observations and 2 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds


422 ;

 

Reeza
Super User

I specified the delimiter as well, but it has trouble determining the end of the data set then. For some reason it thinks it has 37 records now...

 

DATA B_1;
INFILE DATALINES dlm=' ' dsd;
input x y  @@;
datalines;
1 2 3 4 4 5  5 4
;
run;

 Log:

 

16999 DATA B_1;
17000 INFILE DATALINES dlm=' ' dsd;
17001 input x y @@;
17002 datalines;

NOTE: LOST CARD.
RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
17004 ;
x=. y=. _ERROR_=1 _N_=37
NOTE: SAS went to a new line when INPUT statement reached past the end of a line.
NOTE: The data set WORK.B_1 has 36 observations and 2 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds


17004 ;
17005 run;

 

 

 

ballardw
Super User

@Reeza wrote:

I specified the delimiter as well, but it has trouble determining the end of the data set then. For some reason it thinks it has 37 records now...

 

DATA B_1;
INFILE DATALINES dlm=' ' dsd;
input x y  @@;
datalines;
1 2 3 4 4 5  5 4
;
run;

 Log:

 

16999 DATA B_1;
17000 INFILE DATALINES dlm=' ' dsd;
@17001 input x y @@;
17002 datalines;

NOTE: LOST CARD.
RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
17004 ;
x=. y=. _ERROR_=1 _N_=37
NOTE: SAS went to a new line when INPUT statement reached past the end of a line.
NOTE: The data set WORK.B_1 has 36 observations and 2 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds


17004 ;
17005 run;

 

 

 


@Reeza

I think that is the datalines padding to 80 characters:

 

SAS handles data line length with the CARDIMAGE system option. If you use CARDIMAGE, SAS processes data lines exactly like 80–byte punched card images padded with blanks. If you use NOCARDIMAGE, SAS processes data lines longer than 80 columns in their entirety.

 

(but still pads lines less than 80 to 80 with the NOCARDIMAGE option)

athapa1183
Obsidian | Level 7

Thank You Reeza. yes there are more rows. But it works

 

ballardw
Super User

This gets the desired result:

DATA work.B_1;
INFILE DATALINES  ;
input x  y   @@;
datalines;
1 2 3 4 4 5 . 5 4 .
;
run;

A possibly somewhat random example such as this may not actually replicate your issue as datalines limit the use of certain options on the infile and change the behavior of others.

 

It might help to provide an actual line of the data pasted into a code box opened with the {I}.

 

It may also help to explicitly state that the issue seems to revolve around missing values at possibly random places in the actual data, if that is the case.

athapa1183
Obsidian | Level 7

Hi Ballardw,

 

There are no dots here.

ChrisNZ
Tourmaline | Level 20

So if there is no value value then there is simply nothing in the data?

The only way to spot the missing value is 2 spaces in a row?

Is it always just one digit?

 

Comment:

1. SAS will not accept a space as a missing numeric, so you need to read as character and parse

2. The exact code depends on your answers 

Tom
Super User Tom
Super User

You are trying to read 10 values from a line that only has 9.

Perhaps you should first read all of the values first and then later you regroup them into observations?

Try something like this on your actual data an see if finds all of the values.  Then you can worry about figuring out which as the X and which are the Y.

data want ;
  infile test dsd dlm=' ' ;
  row+1;
  input value @@ ;
run;
Obs    row    value

 1      1       1
 2      2       2
 3      3       3
 4      4       4
 5      5       4
 6      6       5
 7      7       .
 8      8       5
 9      9       4

 

athapa1183
Obsidian | Level 7

Thank You

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 10 replies
  • 2145 views
  • 2 likes
  • 5 in conversation