BookmarkSubscribeRSS Feed
Ronein
Meteorite | Level 14

Hello

I am trying to export a sas data set to txt file.

proc export data=sashelp.class outfile="/usr/local/SAS/xxxlexample.txt"      dbms=tab replace;
putnames=no;
run;

 

When I open the  txt file i see that all data is in one row.

I want to export the data and keep same table structure as in original data set.

 

Thanks

Ronekd

4 REPLIES 4
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Define "When I open the  txt file i see that all data is in one row." please.  Are you exporting the file on a Unix system and opening on a Windows system?  This is the most common cause of confusion as Unix and Windows line endings are different.  Notepad cannot cope with that, but Notepad++ and Textpad for example can,  and the data is importable in either by use of the termstr modifier.

 

Otherwise please clarify how your getting the file, and what your opening it with.

Ronein
Meteorite | Level 14

One row means that all data is in one raw

For example:

lets say we have 2 observations with 2 fields

Normal table structure is:

1  10 

2   5  

And I get

1  10  2   5

 

 

 

 

RW9
Diamond | Level 26 RW9
Diamond | Level 26

know what you mean.  What you don't know is that the raw ascii underneath that includes one or two special characters called LF (linefeed) and CR (carriage return) which tells the program when yo break the line.  Unix only uses LF, windows uses LF+CR.  If you transfer your file from Unix to Windows, and use a program which cannot understand this such as notepad, then the program sees LF and thinks, thats not a line ending I will ignore it.

If you want further help, tell us how your exporting - which os as wel, which os your opening on, how your transferring, and what application to open it.

Reeza
Super User

@Ronein wrote:

Hello

I am trying to export a sas data set to txt file.

proc export data=sashelp.class outfile="/usr/local/SAS/xxxlexample.txt"      dbms=tab replace;
putnames=no;
run;

 

When I open the  txt file i see that all data is in one row.

I want to export the data and keep same table structure as in original data set.

 

Thanks

Ronekd


This is likely an artifact of how you're seeing the data, but it should be fine. 

Make sure your text editor has word wrap turned on or try and open it with Excel to see if it's properly formatted. 

 

Otherwise, if you're transferring files from Unix to Windows, the end of line character for Unix is ...

 

Your exact code worked fine for me. 

 

delete_export.PNG

 

Try explicitly setting the end of line character using TERMSTR.

 


filename myout "C:\_localdata\temp\xxxlexample.txt" termstr=CRLF;
proc export data=sashelp.class outfile=myout      dbms=tab replace;
putnames=no;
run;

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!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 4 replies
  • 14512 views
  • 1 like
  • 3 in conversation