Date: Thu, 6 Feb 2003 17:20:19 GMT
Reply-To: julierog@ix.netcom.com
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Roger Lustig <trovato@BELLATLANTIC.NET>
Subject: Re: Processing AGE datasets
Content-Type: text/plain; charset=us-ascii; format=flowed
David:
What you really need is a macro that checks to see how many data sets
there are, and then writes the SET statement for you.
Something like:
%macro howmany(libname,prefix,output);
%let flag=NO;
%* Maximum number of files;
%let &lastfile=100;
%* Loop until you find the last file;
% do %until(&flag=YES);
%if (%sysfunc(exist(&libname..&prefix.lastfile))) %then %let flag=YES;
%else %let lastfile = %eval(&lastfile - 1);
%end;
%* Start your DATA step;
data &output;
set
%* Enumerate the files you want in the SET statement;
%do I=1 %to &lastfile;
&libname..&prefix.&I
%end;
%* Remember the semicolon!;
;
%mend;
*** Invoke the macro;
%howmany(oldlib,DAT,newlib.newfile)
*** Do your selection and anything else;
where <selection criterion>;
<other SAS statements>;
run;
OK?
Roger
David Kellerman wrote:
> I have a group of datasets in a database created by AGEing... i.e.: DAT1;DAT2;DAT3;DAT4 ... DATxxx.(maximum 100)
>
> Perhaps I am going about this the hard way, but I want to be able to process the x number of datasets in a loop, selecting off specific records from each dataset. I can't use a SET statement because I do not know in advance how many datasets there are. I attempted to write a macro to go through, but have not been able to get it to work as yet.
>
> Any suggestions. I would think if SAS created the AGEing process, there would be a simple way to process each dataset in the group.
>
> David
>
>
>
> ---------------------------------
> Do you Yahoo!?
> Yahoo! Mail Plus - Powerful. Affordable. Sign up now