double trailing problem

Reply
New Contributor
Posts: 2

double trailing problem

when I ran the following program, I got lots of observations with missing value and wrong input for the second line of data.  what is wrong here?

in the log:

the ruler for dataline is way longer than the data I have, see attached here:

110  data pointer;

111  input x1 2. y1 2. z1 $3. @@;

112  DATALINES;

NOTE: Invalid data for x1 in line 114 6-7.

RULE:      ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+

114        2837ABC9676DEF8765GHI

x1=. y1=96 z1=76D _ERROR_=1 _N_=13

NOTE: Invalid data for x1 in line 114 13-14.

data pointer;

input x1 2. y1 2. z1 $3. @@;

infile datalines;

DATALINES;

0102AAA0304BBB0506CCC

2837ABC9676DEF8765GHI

;

run;

Respected Advisor
Posts: 4,925

Re: double trailing problem

Posted in reply to jennifer08um

Try this way:

data pointer;

infile datalines missover;

do until (missing(x1));

    input x1 2. y1 2. z1 $3. @;

    if missing(x1) then input;

    else output;

    end;

DATALINES;

0102AAA0304BBB0506CCC

2837ABC9676DEF8765GHI

;

proc print data=pointer; run;

PG

PG
Super User
Posts: 11,343

Re: double trailing problem

Posted in reply to jennifer08um

You don't tell when to release the @@; IF your data is all the same length try this:

data pointer;

infile datalines column=col;

input x1 2. @;

input y1 2. @;

input z1 $3.  @@ ;

if col=22 then input; /* change the value of COL to match the total length of the line+1 or try the LENGTH option on the infile statement.*/

DATALINES;

2837ABC9676DEF8765GHI

0102AAA0304BBB0506CCC

2837ABC9676DEF8765GHI

;

run;

Valued Guide
Posts: 2,177

Re: double trailing problem

Shouldn't the flowover behaviour move it forward once the buffer is exhausted?

Or is dataline handling different from file buffer handling

Respected Advisor
Posts: 4,925

Re: double trailing problem

With formatted input, you would need every line to be a multiple of 7 characters for the flowover to work out. - PG

PG
Valued Guide
Posts: 2,177

Re: double trailing problem

Multiples of 7 are what that input statement demands

Respected Advisor
Posts: 4,925

Re: double trailing problem

Exactly, but the line is padded with blanks up to a length that is not a multiple of 7. So when the input flows to the next line, input fields are out of sync.

PG
Respected Advisor
Posts: 4,925

Re: double trailing problem

This for example,

data pointer;

input x1 2. y1 2. z1 $4. @@;

DATALINES;

0102AAAA0304BBBB0506CCCC

2837ABCD9676EFGH8765IJKL

;

works, sort of, because lines are a multiple of 8 in length.

PG

PG
Valued Guide
Posts: 2,177

Re: double trailing problem

Good reasons to anticipate reading the data from a file

I know of no one else using PARMCARDS (other than our esteemed colleague)

But now  I know a good distinction between streamed cards and streamed parmcards

Respected Advisor
Posts: 3,799

Re: double trailing problem

Posted in reply to jennifer08um

CARD/DATALINES are fixed length records.  You need variable length records like you would have by default with an external file. PARMCARDS; can do that with stream data.

filename ft15f001 temp;
data pointer;
   infile ft15f001;
  
input x1 2. y1 2. z1 $3. @@;
   parmcards;
0102AAA0304BBB0506CCC
2837ABC9676DEF8765GHI
;
run;
Trusted Advisor
Posts: 3,214

Re: double trailing problem

Posted in reply to jennifer08um

You are using datalines...  notice the _N_=13 in the message.

Just change your code adding a line with "put _All_ _infile_ ; list ; "  and see what is telling you that.

The fixed record length is 80 that is default  of using the Hollerith cards in the 1970's. I don't expect Jeniffer will make that association.

After reading 11 times your 7 bytes (yes all extended with spaces) it will move to the second input record. But is not aligned anymore to your expectations.   

SAS(R) 9.4 Statements: Reference, Third Edition The datalines is associated with the cardimage option.

The shipped default of FT15F001 SAS(R) 9.4 System Options: Reference, Third Edition (parmcards spooling file) is coming from the Fortran language .

The parmcards is not documented anymore as a SAS statement it has a special meaning/usages on interfacing parameters to some procedures.

By that I would not advice to use that. I like building on documented processing not on hidden features. 

---->-- ja karman --<-----
New Contributor
Posts: 2

Re: double trailing problem

Thank you all so much for your answers. The discussion here really helps to solve my problem.

I finally used compress function to remove the blanks, as following:

data p;

infile datalines;

_infile_=compress(_infile_);

input x1 2. y1 2. z1 $3. @@;

datalines;

0102AAA0304BBB0506CCC

2837ABC9676DEF8765GHI

run;

Ask a Question
Discussion stats
  • 11 replies
  • 402 views
  • 1 like
  • 6 in conversation