<?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 How to create header in txt file export that includes count of rows/observations in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-header-in-txt-file-export-that-includes-count-of/m-p/483876#M31370</link>
    <description>&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;Hello all,&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;I have the following code and my goal is to have a txt. export with a header that includes the number of rows/obs from my dataset. &lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA have;
SET have END=EOF;
file "filepath.txt" dlm='|';

put (_all_)(~);
IF EOF then 
	do;
		put 'Number of Rows:'_n_:Z7.;		
	end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;As it is now, the only way I could get _n_ to include a count of rows/obs was to put it at the end. When&amp;nbsp;I used: &lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;if _n_&amp;gt;0 then&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;do;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;put 'Number of Rows:'_n_:z7.;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;end;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;then the header was at the top of the file, but _n_ = 1. &lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;Any help is much appreciated.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;Thank you.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 03 Aug 2018 18:32:19 GMT</pubDate>
    <dc:creator>Paul628</dc:creator>
    <dc:date>2018-08-03T18:32:19Z</dc:date>
    <item>
      <title>How to create header in txt file export that includes count of rows/observations</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-header-in-txt-file-export-that-includes-count-of/m-p/483876#M31370</link>
      <description>&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;Hello all,&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;I have the following code and my goal is to have a txt. export with a header that includes the number of rows/obs from my dataset. &lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA have;
SET have END=EOF;
file "filepath.txt" dlm='|';

put (_all_)(~);
IF EOF then 
	do;
		put 'Number of Rows:'_n_:Z7.;		
	end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;As it is now, the only way I could get _n_ to include a count of rows/obs was to put it at the end. When&amp;nbsp;I used: &lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;if _n_&amp;gt;0 then&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;do;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;put 'Number of Rows:'_n_:z7.;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;end;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;then the header was at the top of the file, but _n_ = 1. &lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;Any help is much appreciated.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;Thank you.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Aug 2018 18:32:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-header-in-txt-file-export-that-includes-count-of/m-p/483876#M31370</guid>
      <dc:creator>Paul628</dc:creator>
      <dc:date>2018-08-03T18:32:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to create header in txt file export that includes count of rows/observations</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-header-in-txt-file-export-that-includes-count-of/m-p/483884#M31373</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
	select nobs into :rowcount
		from dictionary.tables
			where upcase(libname) = "SASHELP" and upcase(memname) = "CLASS";
quit;

data _null_;
	SET sashelp.class;
	file "!USERPROFILE\Desktop\want.txt" dlm='|';

	if _n_ = 1 then
		put "Number of Rows: &amp;amp;rowcount.";
	put (_all_)(~);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 03 Aug 2018 19:09:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-header-in-txt-file-export-that-includes-count-of/m-p/483884#M31373</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2018-08-03T19:09:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to create header in txt file export that includes count of rows/observations</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-header-in-txt-file-export-that-includes-count-of/m-p/483887#M31374</link>
      <description>&lt;P&gt;One way--maybe not the best way--is to use CALL SYMPUTX in a prior step. This way, you can store the total number of observations in a macro variable that you call when you export the text file. In this example, the number of observations is printed above the list of values. I'm not sure if this is exactly what you're looking for, but it may help.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input x @@;
datalines;
1 2 3 4 5 6 7 8 9 0 
;
run;
proc print;
run;

data _null_;
   set have;
   total = _n_ ;
   call symputx("macro_total", total);
   run; 
data _null_;
	set have;
	file "c\file.txt";
	if _n_ = 1 then do;
	   put "&amp;amp;macro_total";
	   end;
    put x;
	run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 03 Aug 2018 19:17:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-header-in-txt-file-export-that-includes-count-of/m-p/483887#M31374</guid>
      <dc:creator>svh</dc:creator>
      <dc:date>2018-08-03T19:17:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to create header in txt file export that includes count of rows/observations</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-header-in-txt-file-export-that-includes-count-of/m-p/483932#M31385</link>
      <description>&lt;P&gt;Worked like a charm!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Paul&lt;/P&gt;</description>
      <pubDate>Fri, 03 Aug 2018 21:47:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-header-in-txt-file-export-that-includes-count-of/m-p/483932#M31385</guid>
      <dc:creator>Paul628</dc:creator>
      <dc:date>2018-08-03T21:47:49Z</dc:date>
    </item>
  </channel>
</rss>

