<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to create .txt file with a header and Trailer in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-txt-file-with-a-header-and-Trailer/m-p/314358#M21223</link>
    <description>&lt;P&gt;Not worked &lt;img id="smileysad" class="emoticon emoticon-smileysad" src="https://communities.sas.com/i/smilies/16x16_smiley-sad.png" alt="Smiley Sad" title="Smiley Sad" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 25 Nov 2016 19:31:07 GMT</pubDate>
    <dc:creator>tvbMadhu</dc:creator>
    <dc:date>2016-11-25T19:31:07Z</dc:date>
    <item>
      <title>How to create .txt file with a header and Trailer</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-txt-file-with-a-header-and-Trailer/m-p/314338#M21221</link>
      <description>&lt;P&gt;Hi ,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I am working on a dataset &lt;/SPAN&gt;&lt;SPAN&gt;to create an out put txt file with header and trailer records .&lt;/SPAN&gt;The header record which is the first line in the file and&amp;nbsp;trailer record as&amp;nbsp;the last line in the file .&lt;/P&gt;&lt;P&gt;EX:&amp;nbsp;If there were,3 records then the header field as 00000 . &amp;nbsp;and trailer&amp;nbsp;as&amp;nbsp;&lt;SPAN&gt;0003 ( count of records).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Could anyone send me the&amp;nbsp;code.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Madhu&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;Script:&amp;nbsp;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;%let filePath = /user/home/test;&lt;BR /&gt;libname test '/user/home/test/';&lt;BR /&gt;%include 'user/home/test/TDpwd.txt';&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;CONNECT TO TERADATA (user=&amp;amp;user password=&amp;amp;password server=oneview mode=teradata);&lt;BR /&gt;create table test.test_data as&lt;BR /&gt;select * from connection to teradata(&lt;BR /&gt;SELECT * from 5pt.test24&lt;BR /&gt;);&lt;BR /&gt;disconnect from teradata;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;Data test.test_result;&lt;BR /&gt;set test.test_data;&lt;BR /&gt;file "&amp;amp;filePath/test.data_2016";&lt;BR /&gt;put&lt;BR /&gt;Name $ 1 - 17&lt;BR /&gt;City $ 18 - 25&lt;BR /&gt;Country $ 26 - 30&lt;BR /&gt;Id $ 31 - 46&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;Output:&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;00000 ( header)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thomas Newjersy USA 1000&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;David Newjersy USA 1212&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Rahul&amp;nbsp;Virginia&amp;nbsp;USA 2002&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;00003 (trailer)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Nov 2016 17:58:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-txt-file-with-a-header-and-Trailer/m-p/314338#M21221</guid>
      <dc:creator>tvbMadhu</dc:creator>
      <dc:date>2016-11-25T17:58:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to create .txt file with a header and Trailer</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-txt-file-with-a-header-and-Trailer/m-p/314348#M21222</link>
      <description>&lt;P&gt;1.&lt;/P&gt;
&lt;P&gt;Identifies first record in a data step&lt;/P&gt;
&lt;P&gt;If _n_=1 then do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;lt;insert header record&amp;gt;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. Identify last record&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Set have end=eof;&lt;/P&gt;
&lt;P&gt;if eof then do;&lt;/P&gt;
&lt;P&gt;&amp;lt;insert trailer record here&amp;gt;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Nov 2016 18:30:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-txt-file-with-a-header-and-Trailer/m-p/314348#M21222</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-11-25T18:30:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to create .txt file with a header and Trailer</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-txt-file-with-a-header-and-Trailer/m-p/314358#M21223</link>
      <description>&lt;P&gt;Not worked &lt;img id="smileysad" class="emoticon emoticon-smileysad" src="https://communities.sas.com/i/smilies/16x16_smiley-sad.png" alt="Smiley Sad" title="Smiley Sad" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Nov 2016 19:31:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-txt-file-with-a-header-and-Trailer/m-p/314358#M21223</guid>
      <dc:creator>tvbMadhu</dc:creator>
      <dc:date>2016-11-25T19:31:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to create .txt file with a header and Trailer</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-txt-file-with-a-header-and-Trailer/m-p/314367#M21224</link>
      <description>&lt;P&gt;Here's a fully worked example. You'll need to modify it to fit your data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
	set sashelp.class END=EOF; /*END creates a variable EOF that lets you know when you are on the last record*/
	file 'C:\_localdata\temp\test.txt' dlm=",";

	*Header record;
	If _n_=1 then
		do;
			put '0000';

			/*Output header record with column names - manual type in names*/
			put 'Name, Sex, Age, Height, Weight';
		end;

	put name sex age height weight;

	*Rest of your SAS code;
	/*Trailer record*/
	if eof then
		do;
			put _N_ : z4.; /*Put number of records into the file, with a format of 0000, leading zeroes*/
		end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 25 Nov 2016 20:41:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-txt-file-with-a-header-and-Trailer/m-p/314367#M21224</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-11-25T20:41:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to create .txt file with a header and Trailer</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-txt-file-with-a-header-and-Trailer/m-p/314416#M21226</link>
      <description>&lt;PRE&gt;
CODE NOT TESTED.

ods csvall file='c:\temp\x.csv';
title 'xxxxxxxxxx';
footnote 'yyyyyyyyyy';
proc print data=sashelp.class;run;
ods csvall colse;


&lt;/PRE&gt;</description>
      <pubDate>Sat, 26 Nov 2016 04:20:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-txt-file-with-a-header-and-Trailer/m-p/314416#M21226</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-11-26T04:20:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to create .txt file with a header and Trailer</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-txt-file-with-a-header-and-Trailer/m-p/314496#M21229</link>
      <description>&lt;P&gt;Thanks and Apreciate Reeza, It is working&amp;nbsp;&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;little more details to be added &amp;nbsp;, header and trailer starts with first column&amp;nbsp;and ends with the last column of the record&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;ex: Output :&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;AL16 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0000&lt;BR /&gt;Thomas New Jersy USA 1000&lt;BR /&gt;David &amp;nbsp; &amp;nbsp; New Jersy USA 1000&lt;BR /&gt;Rahul &amp;nbsp; &amp;nbsp; Virginia &amp;nbsp; &amp;nbsp; &amp;nbsp;USA 2002&lt;BR /&gt;DL99 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0003&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;U&gt;script:&lt;/U&gt;&lt;/P&gt;&lt;P&gt;If _n_=1 then&lt;BR /&gt;do;&lt;BR /&gt;put '0000';&lt;BR /&gt;&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;put name,city,country,id ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if eof then&lt;BR /&gt;do;&lt;BR /&gt;put _N_ : z4.;&amp;nbsp;&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Madhu&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 26 Nov 2016 23:47:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-txt-file-with-a-header-and-Trailer/m-p/314496#M21229</guid>
      <dc:creator>tvbMadhu</dc:creator>
      <dc:date>2016-11-26T23:47:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to create .txt file with a header and Trailer</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-txt-file-with-a-header-and-Trailer/m-p/442674#M28560</link>
      <description>Excelent</description>
      <pubDate>Tue, 06 Mar 2018 00:26:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-txt-file-with-a-header-and-Trailer/m-p/442674#M28560</guid>
      <dc:creator>sin_golbarg</dc:creator>
      <dc:date>2018-03-06T00:26:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to create .txt file with a header and Trailer</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-txt-file-with-a-header-and-Trailer/m-p/442675#M28561</link>
      <description>excellent</description>
      <pubDate>Tue, 06 Mar 2018 00:27:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-txt-file-with-a-header-and-Trailer/m-p/442675#M28561</guid>
      <dc:creator>sin_golbarg</dc:creator>
      <dc:date>2018-03-06T00:27:00Z</dc:date>
    </item>
  </channel>
</rss>

