Date: Thu, 7 Mar 2002 22:24:24 +1300
Reply-To: Don Stanley <don_stanley@XTRA.CO.NZ>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Don Stanley <don_stanley@XTRA.CO.NZ>
Subject: Re: is there any efficient way concatenating SAS data sets?
Content-Type: text/plain; charset=us-ascii
This gets around the need to check the table existence and makes the
datastep somewhat simpler to understand ...
It may however in some circumstances be impacted by the maximum size of
a macro variable ...
data x1 ; y=2 ; run ;
data x2 ; y=7 ; run ;
proc sql noprint ;
select trim(libname) || '.' || memname into: dataset_list separated by
' ' from sashelp.vtable
where memtype = 'DATA' and libname = 'WORK' and memname like 'X%'
;
quit ;
data x3 ; set &dataset_list ; run ;
Don
Jim Groeneveld wrote:
>
> P.L
>
> %macro land1980;
> data income.land1980;
> retain lyr tyr lage sex big4 pr_app degree lang warea numwith avgtargt
> avgincwt num_w_o avgincwo totnum big5 diffcur diffcon yrcan
> a b c reg_obs ;
> set
> %do i=1 %to 1502;
> %IF (%SYSFUNC(EXIST(table&i))) %THEN table&i;
> %end;
> ;
> run;
> %mend land1980;
>
> %land1980;
>
> Regards - Jim.
> --
> Y. (Jim) Groeneveld, MSc IMRO TRAMARKO tel. +31 412 407 070
> senior statistician, P.O. Box 1 fax. +31 412 407 080
> senior data manager 5350 AA BERGHEM IMRO TRAMARKO: a CRO
> J.Groeneveld@ITGroups.com the Netherlands in clinical research
>
> My computer beeps when it complains; I complain when it beeps
>
> Notice of confidentiality: this e-mail may contain confidential information
> intended for the addressed recipient only.
> If you have received this e-mail in error please delete this e-mail and
> please notify the sender so that proper delivery
> can be arranged.
>
> > -----Original Message-----
> > From: P. L [SMTP:li_9@HOTMAIL.COM]
> > Sent: Wednesday, March 06, 2002 4:56 PM
> > To: J.Groeneveld@ITGROUPS.COM
> > Subject: Re: is there any efficient way concatenating SAS data sets?
> >
> > Jim,
> >
> > Thanks for your sample code. I've decided to use the following macro, but
> > have some trouble to put your code into it. Any suggestion will be
> > appreciated.
> >
> > P. L
> >
> > %macro land1980;
> > data income.land1980;
> > retain lyr tyr lage sex big4 pr_app degree lang warea numwith avgtargt
> > avgincwt num_w_o avgincwo totnum big5 diffcur diffcon yrcan
> > a b c reg_obs ;
> > set
> > %do i=1 %to 1502;
> > table&i
> > %end;
> > ;
> > run;
> > %mend land1980;
> >
> > %land1980;
> >
> >
> >
> > On Wed, 6 Mar 2002 13:16:47 +0100, Jim Groeneveld
> > <J.Groeneveld@ITGROUPS.COM> wrote:
> >
> > >Y.L.
> > >
> > >%IF ( %SYSFUNC(EXIST(&Table)) EQ 0 ) %THEN do not include the table in
> > >concatenation.
> > >
> > >Regards - Jim.
> > >--
> > >Y. (Jim) Groeneveld, MSc IMRO TRAMARKO tel. +31 412 407 070
> > >senior statistician, P.O. Box 1 fax. +31 412 407 080
> > >senior data manager 5350 AA BERGHEM IMRO TRAMARKO: a CRO
> > >J.Groeneveld@ITGroups.com the Netherlands in clinical research
> > >
> > >My computer beeps when it complains; I complain when it beeps
> > >
> > >Notice of confidentiality: this e-mail may contain confidential
> > information
> > >intended for the addressed recipient only.
> > >If you have received this e-mail in error please delete this e-mail and
> > >please notify the sender so that proper delivery
> > >can be arranged.
> > >
> > >> -----Original Message-----
> > >> From: P. L [SMTP:li_9@HOTMAIL.COM]
> > >> Sent: Wednesday, March 06, 2002 12:05 AM
> > >> To: SAS-L@LISTSERV.UGA.EDU
> > >> Subject: Re: is there any efficient way concatenating SAS data
> > sets?
> > >>
> > >> On Tue, 5 Mar 2002 13:59:49 -0800, Dale McLerran
> > >> <stringplayer_2@YAHOO.COM>
> > >> wrote:
> > >>
> > >> >P.L,
> > >> >
> > >> >If you have datasets named table1-table2000, then naming the datasets
> > >> >can be done easily in a macro.
> > >> >
> > >> >%macro concat;
> > >> >data all_tables;
> > >> > set %do i=1 %to 2000; table&i(in=table&i) %end; ;
> > >> > table = table1 %do i=2 %to 2000; + &i*table&i %end; ;
> > >> >run;
> > >> >%mend;
> > >> >
> > >> >%concat
> > >> >
> > >> >
> > >> >I assume that you want to keep track of the original source table.
> > >> >The variable TABLE as constructed above will keep track of which
> > >> >of the 2000 original tables was the source table.
> > >> >
> > >> >Dale
> > >> >
> > >> >
> > >> >--- "P. L" <li_9@HOTMAIL.COM> wrote:
> > >> >> I'll use SET to concatenating about 2000 SAS data sets
> > >> >> (table1-table2000).
> > >> >> Is there any efficient way to complete the job without listing each
> > >> >> file?
> > >> >> Any help will be greatly appreciated.
> > >> >>
> > >> >> P.L
> > >> >
> > >> >
> > >> >=====
> > >> >---------------------------------------
> > >> >Dale McLerran
> > >> >Fred Hutchinson Cancer Research Center
> > >> >mailto: dmclerra@fhcrc.org
> > >> >Ph: (206) 667-2926
> > >> >Fax: (206) 667-5977
> > >> >---------------------------------------
> > >> >
> > >> >__________________________________________________
> > >> >Do You Yahoo!?
> > >> >Try FREE Yahoo! Mail - the world's greatest free email!
> > >> >http://mail.yahoo.com/
> > >>
> > >> Dale,
> > >>
> > >> Thanks for your very useful SAS code. I have one more question: if some
> > >> tables are missing and the actual number is less than 2000 (let me say,
> > >> there might be 10 files missing from table1-table2000, but I don't want
> > to
> > >> bother to know which one). How can I ask to SAs to avoid reading these
> > >> missing tables? Thanks again.
> > >>
> > >> Y.L
--
Don Stanley, B.SC, Dip O.R.S, MNZCS
EMAIL:: don_stanley@xtra.co.nz, don@sysware.co.nz
Author:: Beyond the obvious with SAS Screen Control Language.
Author:: Solutions for your GUI Applications Development Using SAS/AF
FRAME Technology
http://www.sysware.co.nz ,
http://www.geocities.com/don_stanley_nz/don_home.htm
|