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

Hello,

I am trying to export a comma delimited txt file from a table on a data set that has several variables, but when I export it from SAS, my txt file does not appear as a table as the original file did.

The following is how I wrote my EXPORT function:

PROC EXPORT DATA=OutFile
OUTFILE='/folders/myfolders/sasuser.v94/OutFile.txt'
DBMS=CSV;
RUN;

 

And this is how most of my data appears on the exported txt file:

 

SAS error.png

I appreciate any and all help!

Also, I am using SAS university edition.

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
6 REPLIES 6
PeterClemmensen
Tourmaline | Level 20

Can you post an example of what your data looks like in the SAS data set? And what do you want your csv file to look like? With or without headers?

daft22
Fluorite | Level 6

Hello!

I would indeed like headers since they are included in the original file. The original file is a space delimited txt file.

 

SAS Example.png

I apologize for blurring out everything; the above quoted variables are my headers, and the bottom variables each correspond to each header variable in order.

 

Again, I need to export my data set, which used this original space delimited txt file, into a comma delimited txt file.

Thank you for your help!

Tom
Super User Tom
Super User

If you just want to covert the file and do not actually need to process it in SAS then you can just read and write in one data step.

Looks like you have 11 columns.

data _null_;
  infile 'source.txt' truncover ;
  file 'target.csv' dsd termstr=crlf ;
  input (col1-col11) (:$200.);
  put col1-col11;
run;
daft22
Fluorite | Level 6

Ah!! That actually works!! 

Thank you so much!

Kurt_Bremser
Super User

University Edition runs in a UNIX virtual machine. UNIX uses a single LF character as line separator, while Windows uses a CRLF combination.

By taking the data step (that proc export creates) from the log and adding a

termstr=CRLF

option to the file statement, you can automatically produce Windows-compatible text files.

AFAIK, proc export has no method to add the termstr option.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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