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:
I appreciate any and all help!
Also, I am using SAS university edition.
Thank you!
Looks like you have line terminators that the Windows notepad does not understand.
What happens when you import it with Excel?
How does it look in notepad++?
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?
Hello!
I would indeed like headers since they are included in the original file. The original file is a space delimited txt file.
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!
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;
Looks like you have line terminators that the Windows notepad does not understand.
What happens when you import it with Excel?
How does it look in notepad++?
Ah!! That actually works!!
Thank you so much!
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 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.