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

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?

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

@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.

View solution in original post

7 REPLIES 7
Jagadishkatam
Amethyst | Level 16

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; 
Thanks,
Jag
whymath
Barite | Level 11
The dlmstr=';' may cover the dlm='09'x
whymath
Barite | Level 11
I will do it next time, thanks for your kindly remind.
Ksharp
Super User

proc import  

 dlm = '3B09'x

whymath
Barite | Level 11
Thanks, that works.
Tom
Super User Tom
Super User

@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.

CFC_SAS_Communities_400x225.jpgCFC_SAS_Communities_400x225.jpg

Call for content now open!

It's your turn to help shape SAS Innovate 2027. Share your expertise and inspire the SAS community.

Submit your proposal →

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 7 replies
  • 7174 views
  • 4 likes
  • 5 in conversation