Date: Wed, 10 Jul 2002 15:14:51 -0400
Reply-To: "Fehd, Ronald J. (PHPPO)" <rjf2@CDC.GOV>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Fehd, Ronald J. (PHPPO)" <rjf2@CDC.GOV>
Subject: Re: Writing multiple ASCII files with dynamic filenames
Content-Type: text/plain
From: Jane Folske [mailto:janecynthia@HOTMAIL.COM]
> I have a very large SAS dataset containing one million observations.
> These observations are simulated data in random order.
> I need to write out 1,000 flat ASCII text files of 1,000 observations
each.
ah, Peter beat me to it,
but here's an alternate view of the code, anyway.
examine the file options filename = and filevar
%LET PATH = C:\TEMP;
filename PRNTFILE "&PATH.";
data _NULL_;
length FileVar $ 200;
retain FileVar "&PATH."
FileN
Obs 0;
do until(EndoFile);
set LIBRARY.ONE_MILLION_OBS
end = EndoFile;
Obs+1;%*count the obs;
%*increment the FileNmbr every 1000 obs;
if not mod(Obs,1000) then FileN +1;
file PRNTFILE
filevar = FileVar
mod;
FileVar = "&PATH.\FILE"
!! put(FileN,z4.) %*pad FileNmbr with leading zeros;
!! '.txt';
put stuff=;
%*do until(EOF);end;
stop;
run;
Ron Fehd the macro maven CDC Atlanta GA USA RJF2@cdc.gov
OpSys: Win_Pro Ver: 8.2
--> cheerful provider of UNTESTED SAS code from the Clue?Gee!Wrx <--
|