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.
Code I use is:
PROC IMPORT DATAFILE=REFFILE
DBMS=TAB
OUT= work.TESTDP replace;
guessingrows=100;
DELIMITER = '|';
GETNAMES=NO;
RUN;
Thanks for your help!
@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.
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.
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.
@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.
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!
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.
Ready to level-up your skills? Choose your own adventure.