Help using Base SAS procedures

Problem With Bad Data

Accepted Solution Solved
Reply
Super Contributor
Posts: 358
Accepted Solution

Problem With Bad Data

Hi All:

Not sure whether to post in this forum, but it seems the best fit.

I am running the following code reading a not too large file:

  data work01;

  infile "my\file\name.txt"   lrecl=400 pad missover end=eof;

  input @001 var01 $char400.; 

There is a lot of "bad" data in the file - commas, special characters, etc.

My problem is that when a single quote appears in the data (as in the name: O'Leary) the read seems to stop

at that point and I get no more data.  This is only about half way through the data.

There is no indication in the log that any problem was encountered.

Any ideas how I can get past this?  I need to keep the data as it is (bad characters and all) for the output.

Thanks in advance.


Accepted Solutions
Solution
‎09-27-2012 12:04 PM
Respected Advisor
Posts: 3,777

Re: Problem With Bad Data

Maybe you need INFILE statement option IGNOREDOSEOF.

View solution in original post


All Replies
Solution
‎09-27-2012 12:04 PM
Respected Advisor
Posts: 3,777

Re: Problem With Bad Data

Maybe you need INFILE statement option IGNOREDOSEOF.

Super Contributor
Posts: 358

Re: Problem With Bad Data

Correct on the first try!

Wonder why this option has anything to do with what I assume is quoted text?

Respected Advisor
Posts: 3,777

Re: Problem With Bad Data

It is not a quote just look like it.  Use LIST statement and if it is unprintable control character it will show the line in HEX and you can see what the character actually is.

PROC Star
Posts: 1,099

Re: Problem With Bad Data

I have often hit problems where someone has used a document editor like Microsoft Word to prepare data. Word will automatically change many characters, for instance the double quote " character to what it calls smartquotes, which have different open and close characters. SAS frequently coughs up a hairball when it sees these.

Tom

Trusted Advisor
Posts: 2,113

Re: Problem With Bad Data

The control character was probably a  (ctrl-Z).  Back in the days of DOS, and version 6 of PC SAS, that was still in use and has been maintained in SAS as an EOF character of for PC SAS since.  SAS will read most other control characters into a character variable.

Doc Muhlbaier

Duke

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 222 views
  • 0 likes
  • 4 in conversation