How to import a .txt file which has both semicolon and tab as delimiters ?
I have tried dlm = "; '09'x" but happened to an error. Can somebody give me any hints?
@whymath wrote:
How to import a .txt file which has both semicolon and tab as delimiters ?
I have tried dlm = "; '09'x" but happened to an error. Can somebody give me any hints?
You can either find the hexcode for semi-colon (3B) and include it in your hex literal along with the 09 for the tab character.
Or you can use a variable to hold the list of delimiters.
dlm=';' || '09'x ;
infile .... dlm=dlm ... ;
Note that if you use a variable to hold the list of delimiter characters then you can actually change it during the data step.
Hope this will help
use the dlmstr=';'
Specifies either a character string or the value of a character variable as the delimiter.
data a;
infile 'C:\sas\example1.csv' dlm='09'x dlmstr=';' dsd truncover;
input fname $ lname $ age;
run;
Please post a few lines of your .txt file into a window opened with the {i} button, so we have something to test code against.
proc import
dlm = '3B09'x
@whymath wrote:
How to import a .txt file which has both semicolon and tab as delimiters ?
I have tried dlm = "; '09'x" but happened to an error. Can somebody give me any hints?
You can either find the hexcode for semi-colon (3B) and include it in your hex literal along with the 09 for the tab character.
Or you can use a variable to hold the list of delimiters.
dlm=';' || '09'x ;
infile .... dlm=dlm ... ;
Note that if you use a variable to hold the list of delimiter characters then you can actually change it during the data step.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.