DATA Step, Macro, Functions and more

Read Pipe Delimited File

Reply
Contributor
Posts: 60

Read Pipe Delimited File

[ Edited ]

Hi,

 

I am faicng an issue while reading Pipe delimeted file. there is a single quotes in between two field due to which its getting clubed together in one field.

Input data 

123456789|'|9820 SW 120TH ST| |

OUTPUT DATA

123456789 |9820 SW 120TH ST| |

 

i am using below code

DATA NEW;
LENGTH ACCOUNT $16. addr_1 $30. addr_2 $30. addr_3 $30. addr_4 $30. ;
INFILE "/filelocation/test.txt" DSD DLM='|' ;
INPUT ACCOUNT  addr_1  addr_2  addr_3  addr_4 .$ ;
RUN;

 

Highlighted one getting combined into one.

can anyone please suggest me how to handle it. and I am not sure which row and column can have this value.

 

Thanks

Super User
Posts: 17,912

Re: Read Pipe Delimited File

Remove DSD option

Contributor
Posts: 60

Re: Read Pipe Delimited File

I tried removing DSD option but now data is moving ahead of the column.
Super User
Posts: 5,093

Re: Read Pipe Delimited File

In your output data set, which variable should hold the value:

 

9820 SW 120TH ST

 

Would it make a difference if this variable were shifted over, and became the value of ADDR_1?

 

Would single quotes ever appear anywhere else within your data, other than in the characters  |'|  ?

 

Contributor
Posts: 60

Re: Read Pipe Delimited File

it should go to addr2.and we should place in there column.we don't know where that single quotes with appear. and after removing DSD option data is moving ahead of the column
Trusted Advisor
Posts: 1,115

Re: Read Pipe Delimited File

Hi @PravinMishra,

 

I cannot replicate your issue:

DATA NEW;
LENGTH ACCOUNT $16 addr_1 $30 addr_2 $30 addr_3 $30 addr_4 $30;
INFILE cards DSD DLM='|' ;
INPUT ACCOUNT addr_1 addr_2 addr_3 addr_4;
cards;
123456789|'|9820 SW 120TH ST| |
;

Result:

 ACCOUNT     addr_1         addr_2         addr_3    addr_4

123456789      '       9820 SW 120TH ST

(Same result when reading from an external file.)

Contributor
Posts: 60

Re: Read Pipe Delimited File

yes that's true.this should be the out put and I don't in which column single quote will be there
Ask a Question
Discussion stats
  • 6 replies
  • 351 views
  • 0 likes
  • 4 in conversation