08-15-2014 03:29 PM
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. @@;
NOTE: Invalid data for x1 in line 114 6-7.
x1=. y1=96 z1=76D _ERROR_=1 _N_=13
NOTE: Invalid data for x1 in line 114 13-14.
input x1 2. y1 2. z1 $3. @@;
08-15-2014 03:49 PM
Try this way:
infile datalines missover;
do until (missing(x1));
input x1 2. y1 2. z1 $3. @;
if missing(x1) then input;
proc print data=pointer; run;
08-15-2014 04:12 PM
You don't tell when to release the @@; IF your data is all the same length try this:
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.*/
08-15-2014 04:56 PM
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.
08-15-2014 05:06 PM
This for example,
input x1 2. y1 2. z1 $4. @@;
works, sort of, because lines are a multiple of 8 in length.
08-15-2014 05:13 PM
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
08-15-2014 04:24 PM
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.
08-16-2014 03:14 AM
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.
08-18-2014 11:34 AM
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:
input x1 2. y1 2. z1 $3. @@;