BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Sean_OConnor
Fluorite | Level 6

Good Afternoon,

 

I'm attempting to export a file created in SAS to an external database and one of the fields is a free text field which appears to be exporting some records to do lines.

An example of how some of the fields look is as follows.

""" See printout stored in ABC area
(if not found consult document) """

 

Is there a way to fix these issues prior to export in order to have one record per line?

 

Any help is welcome.

 

Sean 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

You can either replace the CR and/or LF characters in your string.  For example you might replace the LF's in the file with | character instead and then write that file to a CSV file.

data for_export;
  set have;
  array _c _character_;
  do _n_=1 to dim(_c);
      _c[_n_] = translate(_c[_n_],'|','0A'x);
  end;
run;

 

Or possibly use something like the macro mentioned here to write the CSV file with quotes around values that including them.

https://communities.sas.com/t5/SASware-Ballot-Ideas/Enhancements-to-INFILE-FILE-to-handle-delimited-...

 

View solution in original post

1 REPLY 1
Tom
Super User Tom
Super User

You can either replace the CR and/or LF characters in your string.  For example you might replace the LF's in the file with | character instead and then write that file to a CSV file.

data for_export;
  set have;
  array _c _character_;
  do _n_=1 to dim(_c);
      _c[_n_] = translate(_c[_n_],'|','0A'x);
  end;
run;

 

Or possibly use something like the macro mentioned here to write the CSV file with quotes around values that including them.

https://communities.sas.com/t5/SASware-Ballot-Ideas/Enhancements-to-INFILE-FILE-to-handle-delimited-...

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 1 reply
  • 339 views
  • 0 likes
  • 2 in conversation