BookmarkSubscribeRSS Feed
PravinMishra
Quartz | Level 8

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

6 REPLIES 6
Reeza
Super User

Remove DSD option

PravinMishra
Quartz | Level 8
I tried removing DSD option but now data is moving ahead of the column.
Astounding
PROC Star

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  |'|  ?

 

PravinMishra
Quartz | Level 8
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
FreelanceReinh
Jade | Level 19

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

PravinMishra
Quartz | Level 8
yes that's true.this should be the out put and I don't in which column single quote will be there

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 2035 views
  • 0 likes
  • 4 in conversation