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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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