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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.