BookmarkSubscribeRSS Feed
dpadman
Calcite | Level 5

Hello,

 

As I import a txt file (with French characters) I notice that for certain rows SAS reads the delimiter (|) as a character which then causes an invalid data error for subsequent variables. Please see snip below. FM should have actually been read as the next variable. 

 

 Capture.PNG

Code I use is:

 

PROC IMPORT DATAFILE=REFFILE
DBMS=TAB
OUT= work.TESTDP replace;
guessingrows=100;
DELIMITER = '|';
GETNAMES=NO;

RUN;

 

Thanks for your help!

4 REPLIES 4
ballardw
Super User

@dpadman wrote:

Hello,

 

As I import a txt file (with French characters) I notice that for certain rows SAS reads the delimiter (|) as a character which then causes an invalid data error for subsequent variables. Please see snip below. FM should have actually been read as the next variable. 

 

 Capture.PNG

Code I use is:

 

PROC IMPORT DATAFILE=REFFILE
DBMS=TAB
OUT= work.TESTDP replace;
guessingrows=100;
DELIMITER = '|';
GETNAMES=NO;

RUN;

 

Thanks for your help!


You told proc import to use the TAB character as the delimiter but your question narrative says that you think | was the delimiter. Which is it?

 

It may help to paste a few lines from the text file (assuming the values are not too sensitive) into a code box opened with the forums {I} icon. Make sure that if you do so you copy text using a text editor such as Notepad or the SAS editor. 

dpadman
Calcite | Level 5
Sorry that was my bad. Even when i run the code with DBMS = DLM (for delimiters other than , or tab) the same error persists.
Can't post lines from the text file due to data privacy.
SASKiwi
PROC Star

If you are running into problems with PROC IMPORT then you may have to resort to a DATA step import where you have more control over the parsing of your data rows.

ballardw
Super User

@dpadman wrote:
Sorry that was my bad. Even when i run the code with DBMS = DLM (for delimiters other than , or tab) the same error persists.
Can't post lines from the text file due to data privacy.

Can you make a text file that looks similar but with non-sensitive values.

Instead of a name like "John" use "JJJJ". If you think the French characters are the issue pick one of those "words" that ends up with a | in the middle and replace the non-special characters with something like XXXX.

 

Only need one or two lines that when you run proc import on with the same syntax behaves the same. Likely the example only needs 3 or 4 variables.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1093 views
  • 0 likes
  • 3 in conversation