BookmarkSubscribeRSS Feed
Calcite | Level 5



I am working in Enterprise Guide 7.1 and trying to put a carriage return at the end of my dataset (the last line of my file), which I am outputting as a text file. However I am not sure the correct syntax to do the carriage return for the end of my dataset (last line of the file). The dataset will always have 37 variables and be a length of 304, but the number rows will change week to week. I am fairly new to this so certainly if I can clarify, I welcome any assistance. Thank you! Here is what I have.


options missing=' ';

data _NULL;

File "/path/path/File_name.txt";

set work.file;


@1 Variable $2.

@3 Variable2 yymmddS10.


@300 Variable 37 $4.;



Thank you !

Super User Tom
Super User

SAS already writes an end of line character at the end of every line it writes to a text file.


Also it looks like you are using Unix. On Unix file system text files normally use LineFeed as the end of line markers as apposed to Windows file systems that use CarriageReturn and LineFeed as the end of line markers.  You can change this by using the TERMSTR= option on the FILE statement.


Why do you want to add an extra carriage return at the end of the file?

If you really just want to write an extra empty line at the end of your file the add an extra PUT statement that runs only on the last observation.


Note you don't need the @ 1 since SAS always starts writing at the first position unless you tell it otherwise.  You also don't need the @ 3 since you just wrote two characters into columns 1 and 2 so the pointer is already at column 3.


data _null_;
  file "/path/path/File_name.txt";
  set work.file end=eof;
  put  Variable $2. Variable2 yymmddS10.
         @300 Variable37 $4.
  if eof then put;
Calcite | Level 5

Thank you for the quick response Tom, i appreciate the detailed explanation and suggestions.  My client is asking for a carriage return to meet their specific design when they import the data.  This item is the last part of this project so hopefully this solution can close out this job. Thank you again.


Regards ~ B_rad

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
  • 2 replies
  • 2 in conversation