Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Import fixed format data into SAS dataset - with error

Status
Not open for further replies.

devon59

Technical User
Nov 30, 2005
18
US
Hi, I am encounter the problem while trying to read this fixed format data into SAS dataset.

The raw data is large about 85 million records total and the layout I was given was
Field Length
ID 8
date 9
amount 12
Source 14

The code I am using is
/**********************/
data gift;
infile 'G:\Database\response.txt' truncover missover lrecl=32767 firstobs=1 ;
input
id$ 1-8
date$ 9-17
amount $ 18-29
source $ 30-43
;
if _ERROR_ then call symput('_EFIERR_',1); /* set ERROR detection macro variable */
run;
/**********************/

For some reasons, SAS only read up to row 3445 and stopped. I found that variable source in row 3445 is empty. Maybe that's the problem but I don't know how to fix it. Could anyone help?

The vendor that sent me this file said the length of the last var, which is Source, could be less than 14 in some cases.

Please help. Thank you very much.
 
Have you looked at the source file using a text editor that can show hex?
I've had problems like this in the past where an "empty" record actually has an end of file character (Hex value 1A).
In fact, I think mine was embedded in a text field. (end of file is also CTRL+Z so I suspect that it was captured at data entry rather than undoing what the operator did previously).
I don't actually know of a way around this other than manually cleaning the source data. I usually use a find replace once I've hit the problem and worked out the source. Another problem that can cause issues is extraneous line-feeds, carriage returns and other high ascii characters.


Chris
Business Analyst, Code Monkey, Data Wrangler.
SAS Guru.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top