Hello,
I'm trying to find an answer for avoiding line breaks/line feeds in an csv output file.
So I want to export a file with multiple columns. One of them is a json string with a lot of qoutes.
It looks like this;
data _null_ ;
/* FILE "&file_export_wait_s" DLM= ';' ; */
set expclang.&_file_name._export;
FILE "&file_export_wait_s" DLM= ';';
if _n_ = 1 then put @1 'CUSTOMER_ID;SUBJECTLINE;PREHEADER;REFERRER;FLEXBANNERS;GLOBALIDS;TEXTS;CONTENT'; /* Add variable names */
put CUSTOMER_ID SUBJECTLINE PREHEADER REFERRER FLEXBANNERS GLOBALIDS TEXTS CONTENT ;
/* put (_all_) (~);*/
run ;
The content is a huge string with json in it. What happens in the csv is that there are linebreaks. How can avoid those?
Thanks
Try adding a sufficient lrecl= option to your file statement.
Thanks! It worked...
@PWS wrote:
What happens in the csv is that there are linebreaks. How can avoid those?
Thanks
What does that mean in detail please? Trying to understand your problem 🙂
When writing the file to csv a lot of text is written in the file. Especially for content, because there is a json string included, looking like this;
see attached file
So one line should start with slgnt19 and the next line should also start with slgnt19.
Can't exactly find yet where to put the lrecl= option
@PWS wrote:
Can't exactly find yet where to put the lrecl= option
On the FILE statement
Thanks! It works
CSV means comma delimited, literally, Comma Separated Values. Why are you using ; as a delimiter if you want a CSV file?
Good question. For now it's because the receiving party is requesting this delimiter.
The delimiter in a CSV file (despite the name) is locale dependent. It is typically the semicolon in French.
You could replace all control characters with spaces with something like:
TEXTS = prxchange("s/[[:cntrl:]]+/ /o", -1, TEXTS);
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.