BookmarkSubscribeRSS Feed
PWS
Fluorite | Level 6 PWS
Fluorite | Level 6

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

10 REPLIES 10
PWS
Fluorite | Level 6 PWS
Fluorite | Level 6

Thanks! It worked... 

Reeza
Super User

@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 🙂

PWS
Fluorite | Level 6 PWS
Fluorite | Level 6

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

 

Reeza
Super User

@PWS wrote:

 

 

Can't exactly find yet where to put the lrecl= option

 


On the FILE statement

http://documentation.sas.com/?docsetId=lestmtsref&docsetTarget=n15o12lpyoe4gfn1y1vcp6xs6966.htm&docs...

PWS
Fluorite | Level 6 PWS
Fluorite | Level 6

Thanks! It works

Reeza
Super User

CSV means comma delimited, literally, Comma Separated Values. Why are you using ; as a delimiter if you want a CSV file?

PWS
Fluorite | Level 6 PWS
Fluorite | Level 6

Good question. For now it's because the receiving party is requesting this delimiter.

PGStats
Opal | Level 21

The delimiter in a CSV file (despite the name) is locale dependent. It is typically the semicolon in French.

PG
PGStats
Opal | Level 21

You could replace all control characters with spaces with something like:

 

TEXTS = prxchange("s/[[:cntrl:]]+/ /o", -1, TEXTS);
PG

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

SAS Enterprise Guide vs. SAS Studio

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 10 replies
  • 2633 views
  • 4 likes
  • 4 in conversation