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-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
  • 12854 views
  • 1 like
  • 3 in conversation