Hi @Tom , Thank you for your response, and apologies for the lack of details. Here is the sample data I'm reading: |11081990|,|41|,|X04|,|N-XYXYXYXY/SAMPLE DUMMY DATA TO T|,|05311999|,|1|,|08-JAN-2001 04.28.19.546000 AM|,|1|,|29-APR-2001 04.55.35.938000 PM|,|08182001|,,,,
|09201978|,|42|,|Y05|,|N-XYXYXY/SAMPLE DUMMY DATA TO TEST THE TRUNCATION OF IMPORTED RECORDS DUE TO THE LONG DATA SAMPLE DUMMY DATA TO TEST THE TRUNCATION OF IMPORTED RECORDS DUE TO THE LONG DATA SAMPLE DUMMY DATA TO TEST THE TRUNCATION OF |,|04211988|,|1|,|10-MAY-1989 05.28.30.550000 AM|,|1|,|20-JUN-1989 03.52.35.942000 PM|,|03031989|,,,,
|12031985|,|43|,|Z06|,|K-XYXYXYXYXYXYXYXY/ SAMPLE DUMMY DATA TO TEST THE TRUNCATION OF IMPORTED RECORDS DUE TO THE L|,|09131988|,|1|,|19-SEP-1988 15.28.19.552000 AM|,|1|,|02-OCT-1988 13.44.15.944000 PM|,|03191988|,,,, If I use the your modified code below: filename original "IMPORT_DATA.csv";
filename fixed "FIXED_IMPORT_DATA.csv";
data _null_;
infile original lrecl=1 recfm=f ;
file fixed termstr=crlf;
input char $char1.;
numpipe + (char='|');
if char='0D'x then return;
else if char='0A'x then do;
if mod(numpipe,2)=1 then put '|' @;
else do;
numpipe=0;
put;
end;
end;
else if char='|' then put '"' @;
else if char='"' then put '""' @;
else put char $char1. @;
run; The FIXED_IMPORT_DATA.CSV will be created with the following records: "11081990","41","X04","N-XYXYXYXY/SAMPLE DUMMY DATA TO T","05311999","1","08-JAN-2001 04.28.19.546000 AM","1","29-APR-2001 04.55.35.938000 PM","08182001",,,,
"09201978","42","Y05","N-XYXYXY/SAMPLE DUMMY DATA TO TEST THE TRUNCATION OF IMPORTED RECORDS DUE TO THE LONG DATA SAMPLE DUMMY DATA TO TEST THE TRUNCATION OF IMPORTED RECORDS DUE TO THE LONG DATA SAMPLE DUMMY DATA TO TEST THE TRUNCATION OF ","04211988","1","10-MAY-1989 05.28.30.550000 AM"
"1","02-OCT-1988 13.44.15.944000 PM","03191988",,,, You may notice that the second record was truncated and the third record was changed.
... View more