Date: Thu, 8 Apr 1999 19:57:14 +0100
Reply-To: Peter Crawford <Peter@CRAWFORDSOFTWARE.DEMON.CO.UK>
Sender: "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From: Peter Crawford <Peter@CRAWFORDSOFTWARE.DEMON.CO.UK>
Subject: Re: output groups of records as text files
In-Reply-To: <87C6DE6B9EF1D1119CDE00805FA7FBA401504F39@mail.dc.state.fl.us>
Dougherty, Kristine <dougherty.kristine@MAIL.DC.STATE.FL.US> writes
>We need to write out delimited ascii files consisting of:
>
>a header record including a file number(e.g. file001)
>200 records
>an eof line,e.g EOF
>
>We need this for a few thousand total records, with each file having up to
>200 observations, so the first file would have obs 1-200, the next file
>201-400, etc.
>
>Thanks for any help you can provide.
>Since I get the list in digest form, if you get this today, I'd appreciate
>your CCing my own e-mail address as well as the list.
>
>Kris Dougherty
>Research & Data Analysis
>FL Dept. of Corrections
>850-410-4487
>dougherty.kristine@mail.dc.state.fl.us
look up the on-line help on the FILEVAR option of the FILE statement.
Through that option, your single data step can generate all required
files without resorting to macro processing
features will include
filename dumf 'dummy' ;* just for reference later;
set <source.data> end = end_inpt;
retain fil_nam 'file0000' fil_num 0;
file dumf filevar = fil_nam linesize = <wide enough>;
if _n_ =1 or mod( _n_, 200 ) =0 then
do;
if _n_ > 1 then
do; * close the preceeding set of 200;
put 'end of file: ' +1 fil_nam @;
if ^end_inpt then put +1 ' but not end of input';
else put +1 ' and end of input';
* and further trailer info as necessary ;
end;
* up the file number;
fil_num + 1 ;
* store number in file name;
substr( fil_nam, 5, 4 ) = put( fin_num, z4.0 );
put 'header: file is' +1 fil_nam ;
* and further heading info as necessary ;
end;
put /* regular line of columns */ ;
if end_inpt then
put 'end of file: ' +1 fil_nam +1 ' and end of input';
run;
--
Peter Crawford