Macros for SAS Application Developers
https://github.com/sasjs/core
mp_cleancsv.sas File Reference

Fixes embedded cr / lf / crlf in CSV. More...

Go to the source code of this file.

Detailed Description

CSVs will sometimes contain lf or crlf within quotes (eg when saved by excel). When the termstr is ALSO lf or crlf that can be tricky to process using SAS defaults. This macro converts any csv to follow the convention of a windows excel file, applying CRLF line endings and converting embedded cr and crlf to lf.

Usage:

fileref mycsv "/path/your/csv";
%mp_cleancsv(in=mycsv,out=/path/new.csv)
Parameters
[in]in=(NOTPROVIDED) Provide path or fileref to input csv. If a period is found, it is assumed to be a file.
[in]out=(NOTPROVIDED) Output path or fileref to output csv. If a period is found, it is assumed to be a file.
[in]qchar=('22'x) Quote char - hex code 22 is the double quote.
Version
9.2
Author
Allan Bowe

Definition in file mp_cleancsv.sas.