DATA Step, Macro, Functions and more

Input datalines with tab

Accepted Solution Solved
Reply
Super Contributor
Posts: 506
Accepted Solution

Input datalines with tab

Hello,

 

I want to create a dataset with character as below where tab is used to separate value.

 

In the second set, the datalines is mixed with space and tab to separate value.

 

Can you please help me with that?

 

Thank you,

 

HHCFX

 

data name1;
input name :$32.  @@;
datalines;
a	b	c	d	e	f
;

data name2;
input name :$32.  @@;
datalines;
a b	c d	e	f
;

 


Accepted Solutions
Solution
‎03-14-2018 08:25 PM
Super User
Posts: 23,357

Re: Input datalines with tab

DLM can specify multiple delimiters. 

This worked for me, by manually entering a space followed by a tab in the editor.

 

data name2;
infile cards dlm=" 	"; *space and tab keyed in;
input name :$32.  @@;
datalines;
a b c d e	f
;

run;

View solution in original post


All Replies
SAS Employee
Posts: 273

Re: Input datalines with tab

Hi @hhchenfx

 

This will work but it is very different than your examples.

 

 

data test;
  input c1 $ c2 $ c3 $ c4 $ c5 $;  
datalines;
a b c d		f
run;

 

Best wishes,

Jeff

Solution
‎03-14-2018 08:25 PM
Super User
Posts: 23,357

Re: Input datalines with tab

DLM can specify multiple delimiters. 

This worked for me, by manually entering a space followed by a tab in the editor.

 

data name2;
infile cards dlm=" 	"; *space and tab keyed in;
input name :$32.  @@;
datalines;
a b c d e	f
;

run;
Super Contributor
Posts: 506

Re: Input datalines with tab

Thanks a lot.

It works great!

HHCFX

Super User
Posts: 10,699

Re: Input datalines with tab

data name2;
infile cards expandtabs;
input name :$32.  @@;
datalines;
a b c d e	f
;
run;
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 130 views
  • 4 likes
  • 4 in conversation