1
votes

I have the following txt file with records in the following way

LEE ATHNOS
1215 RAINTREE CIRCLE
PHOENIX  AZ 85044
JOYCE BENEFIT
85 MAPLE AVENUE
MENLO PARK  CA 94025

These are actually 2 records in multiple lines. The code i am using to input the records

data lineinput;
infile linein;
input Lname $ Fname $ /
      Address $1-20 /
      City & $10. State $ zip $ ;
run;

I am not able to read the 2nd record . Below is the log

NOTE: The infile LINEIN is:
      Filename=\\VBOXSVR\win_7\SAS\DATA\INPUT\linepointer.txt,
      RECFM=V,LRECL=256,File Size (bytes)=105,
      Last Modified=30Jun2015:00:45:47,
      Create Time=30Jun2015:00:32:31

NOTE: LOST CARD.
Lname=JOYCE Fname=BENEFIT Address=MENLO PARK  CA 94025 City=  State=  zip=  _ERROR_=1 _N_=2
NOTE: 6 records were read from the infile LINEIN.
      The minimum record length was 10.
      The maximum record length was 20.
NOTE: SAS went to a new line when INPUT statement reached past the end of a line.
NOTE: The data set WORK.LINEINPUT has 1 observations and 6 variables.
NOTE: DATA statement used (Total process time):
      real time           0.02 seconds
      cpu time            0.01 seconds

on proc print I am getting follwing output enter image description here

ANY idea guys why I am not getting the 2nd record correct.(There is a space between city name so i have used & )

1
@Kyralessa The above information is from SAS Certification Preparation Guide Base Programming text book published by sas.Mukesh Kumar Singh
@MukeshKumarSingh I don't get any error when I paste the above data into SAS via datalines. I wonder if you have a problem with your file? Can you paste into datalines and see if that works?Joe
@Joe Yeah thats working . Then what could be the issue with loading using the file ? I hope it should also work for file !!! Can u check using filename ?Mukesh Kumar Singh
@Joe please look at the log i have pasted in the question . "LOST CARD" is something intresting .Mukesh Kumar Singh
Yes, I have the same issue reading from a file. Trying to recall what causes this; it's something I've seen before. (Add a third record, and you see it get worse, btw.)Joe

1 Answers

2
votes

You need to add an option 'truncover' for it to work in a streaming setting:

filename FT15F001 temp lrecl=512; 
data hipa;
   infile FT15F001 truncover; 
input Lname $ Fname $ /
      Address $1-20 /
      City & $10. State $ zip $ ;
parmcards4;
LEE ATHNOS
1215 RAINTREE CIRCLE
PHOENIX  AZ 85044
JOYCE BENEFIT
85 MAPLE AVENUE
MENLO PARK  CA 94025
;;;;

run;