BookmarkSubscribeRSS Feed
shixin
Calcite | Level 5

Hi SAS experts,

I want to export a sas dataset into excel and it looks something like this:

_________________________________________________________________________________________________

NAME               ID               COMMENTS                                             TIMESTAMP

Heather             123             Heather likes oranges.                              08MAY2013:00:00:00.0000

                                           Doesn't like apples. <<notice the new line

Jonathan           456             John likes grapes. Doesn't like pears          08MAY2013:00:00:00.0000

__________________________________________________________________________________________________

proc export data=comments outfile="...."

    dbms=csv

    replace;

run;

But because of the new line, 'Doesn't like apples' became another NAME. I tried finding ways to read past a new line but most methods could only be applied to importing a dataset.

Is there a way to read past the new line for proc export?

Thanks in advance!

Cheerin

4 REPLIES 4
data_null__
Jade | Level 19

What does the SAS data set look like exactly? 

Reeza
Super User

You say CSV but then Excel, those are two different formats.

CSV is a comma delimited file so your output would be as below. CSV would not have a way to differentiate lines.

Heather,             123,             Heather likes oranges. Doesn't Like apples. ,                             08MAY2013:00:00:00.0000

Are you trying to create an excel file or a CSV file?

In that excel file for the second row, are you expecting a second set of cells or the cell for comments to have 2 lines?

These are different solutions with different approaches...the first is much easier.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

For a cell in an export xls file to have a return you would need to embed the character for it.  In the same way as you would embed RTF code directly into text to get layout functionality.  I doubt also that proc export would be sufficient for that task.  I would suggest moving to ods tagsets.excelxp.   I couldn't see the split char at a quick glance and am leaving now.

ballardw
Super User

I'm willing to bet your original data has all sorts of tabs and line feed or carriage return/line feed characters (user pressed the Enter key depending on OS).

You'll need to clean your data and replace them with a space

BTW, exporting to CSV you likely need to check your data for folks entering mismatched single or double quotes as well.

I have cleaned literally thousands of comments entered by folks and these are very common issues.

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 4 replies
  • 1102 views
  • 0 likes
  • 5 in conversation