BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
dmorrell
Calcite | Level 5

Reading a flat text file in ASCII, fixed length records, fixed-width fields. One field is department name and the word "Café" appears in it. On the records where this happens, INPUT pointer jumps backwards 1 byte and therefore my @xx specs are all off for the remainder of the record and the data gets hosed.

Is there an INFILE option or parm that I can use to keep everything lined up?

thanks

Doug

1 ACCEPTED SOLUTION

Accepted Solutions
Patrick
Opal | Level 21

Are you sure your text file is ASCII and not ANSI or UTF? A good way to check is opening the file with Notepad++ and there check in the encoding menu what it tells you.

Not sure why your pointer would be "jumping backwards" but I sure had already my fun with the "é". There is an "encoding" option available for the infile statement which you should set to the value of your source file.

View solution in original post

3 REPLIES 3
Patrick
Opal | Level 21

Are you sure your text file is ASCII and not ANSI or UTF? A good way to check is opening the file with Notepad++ and there check in the encoding menu what it tells you.

Not sure why your pointer would be "jumping backwards" but I sure had already my fun with the "é". There is an "encoding" option available for the infile statement which you should set to the value of your source file.

dmorrell
Calcite | Level 5

To be more specific, the pointer isn't "jumping backwards". I'm trying to read the field at position 100 (@100) for example, but when there is "Café" in the preceding field, position 100 is blank and the data is actually at 101.

I always assume I'm dealing with ASCII when reading text files on a PC, and the file is sourced from USA. So I downloaded Notepad++, found the encoding was UTF-8, put that option on the INFILE, and it works fine now!

Thanks for the tip!

Doug

Patrick
Opal | Level 21

The encoding of the little e with accent uses obviously 2 bytes but you're only reading the first byte with ASCII (and then you get one byte "behind").

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 1093 views
  • 1 like
  • 2 in conversation