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

Hi,

I am outputting 2 datasets into a pipe delimited txt file, the problem is I'm getting an additional empty row at the last line after the footer, I'm using following code, Please help.

 

options nobomfile missing='';

filename rec "/folder1/folder2/file..txt" 
		mod encoding= 'UTF-8';

data _null_;
file rec notitle dsd delimiter='|';
length lbl $200;
if _n_=1 then do;
	do lbl='HD','supplier',&run_date.,'1.0','0','';
	put lbl @;
	end;
put;
end;
do until(eof);
set have1 end=eof;
put ID1-ID123;
end;
run;

data _null_;
file rec notitle dsd delimiter='|';
length lbl $200;
set have2 end=eof;
put CC1-CC143;
if eof then do lbl= 'FT','supplier',&run_date.,&obs.;
put lbl @;
end;
run;
1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

SAS does NOT write any extra lines at the end of text files.  Each line consists of characters followed by the end of line character(s). Which is the standard format for text files.

 

If you are looking at the file in an editor then the editor is displaying an extra line so you have some place to start appending new lines.

 

Or what ever program you are using to read the file is misinterpreting the end of line character(s) in the file as if they were "record" delimiters.  Check with the manuals for that program whether they have an option to let them process normal text files.

 

Examples of other users that have been stuck with using such misguided programs.

https://communities.sas.com/t5/SAS-Data-Management/Text-File-Output-Node-generating-extra-line-at-en...

https://communities.sas.com/t5/ODS-and-Base-Reporting/Don-t-insert-blank-line-in-csv-file/m-p/130525...

https://stackoverflow.com/questions/35463015/prevent-final-lf-crlf-when-writing-a-text-file/35464019...

 

View solution in original post

1 REPLY 1
Tom
Super User Tom
Super User

SAS does NOT write any extra lines at the end of text files.  Each line consists of characters followed by the end of line character(s). Which is the standard format for text files.

 

If you are looking at the file in an editor then the editor is displaying an extra line so you have some place to start appending new lines.

 

Or what ever program you are using to read the file is misinterpreting the end of line character(s) in the file as if they were "record" delimiters.  Check with the manuals for that program whether they have an option to let them process normal text files.

 

Examples of other users that have been stuck with using such misguided programs.

https://communities.sas.com/t5/SAS-Data-Management/Text-File-Output-Node-generating-extra-line-at-en...

https://communities.sas.com/t5/ODS-and-Base-Reporting/Don-t-insert-blank-line-in-csv-file/m-p/130525...

https://stackoverflow.com/questions/35463015/prevent-final-lf-crlf-when-writing-a-text-file/35464019...

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 687 views
  • 0 likes
  • 2 in conversation