For some reason, my data keeps exporting with a LR end line character instead of a CR LF end line character. I have no idea if this can be fixed during the output in SAS but if it can that'd be great.
Here's how my data looks:
Memberid level
xxx1 2
xxx2 2
xxx3 2
xxx4 2
xxx5 2
And this is the code I'm using to export this data:
PROC EXPORT DATA= work.new_data
outfile= "/windows/data_011420_0312.txt"
dbms = DLM replace;
delimiter="|";
run;
If you are running SAS on Unix then the default will be to use linefeed ('0A'x) as the end of line character. If you are running on Windows then the default will be CRLF ('0D0A'x) instead. You can use the TERMSTR= option on the FILENAME or FILE statement to control that.
To write a delimited text file a DATA step with appropriate FILE and PUT statements is about all you need.
But if you do feel a need to use PROC EXPORT instead then you will need add a FILENAME statement to define a fileref. You will then reference the fileref in the PROC EXPORT statement instead of the raw physical filename. That way you have a place to put the TERMSTR= option.
filename out "/windows/data_011420_0312.txt" termstr=crlf ;
PROC EXPORT DATA= work.new_data
outfile= out replace
dbms = DLM
;
delimiter="|";
run;
Hello,
Your comment was helpful in getting my file encoded with windows CRLF, but i'm noticing that it is causing many of the variables in my file to get dropped/removed. The code I use is exactly as you show, but also using encoding= 'UTF-8' and options nobomfile as I need the file to be encoded in utf-8. Happy to share more info if needed.
Wondering if you've run into this issue and have a potential fix. Thank you!
Please start a NEW question instead of posting on a two year old thread. You can include a link to this if you want.
Include the actual code you ran, any notes or errors from the SAS log.
Is the problem that you values are too long for the default 32K record length? If so then add the LRECL= option to the FILENAME statement to set something longer. In general you can have any length then , but memory limits on particular operating systems might limit you to 10000000 bytes max for LRECL setting. Which should be way longer than any reasonable dataset would require.
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 16. Read more here about why you should contribute and what is in it for you!
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.