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);
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.