Date: Wed, 12 Oct 2011 15:11:41 +0000
Reply-To: abu zafar muyeen <muyeen70@HOTMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: abu zafar muyeen <muyeen70@HOTMAIL.COM>
Subject: Re: Macro to add multiple SAS datasets into one big dataset by
"append or set"
In-Reply-To: <201110121500.p9CApQGb017059@waikiki.cc.uga.edu>
Content-Type: text/plain; charset="iso-8859-1"
Hi Tom,Thanks for your help. Let me try with your code. Abu
> Date: Wed, 12 Oct 2011 11:00:12 -0400
> From: tom.abernathy@GMAIL.COM
> Subject: Re: Macro to add multiple SAS datasets into one big dataset by "append or set"
> To: SAS-L@LISTSERV.UGA.EDU
>
> If your member names consistently follow the pattern XX_... then you could
> do something with that. Basically read in the member names, calculate this
> two letter prefix and then generate code to create each BIG_XX dataset.
>
> Here is an example using PROC CONTENTS to get the member names. Then
> generate one DATA step for each prefix group.
>
> %let inlib=mylib;
> %let outlib=work;
>
> proc contents data=&inlib.._all_ noprint out=contents;
> run;
>
> data bigs;
> length prefix $2;
> set contents(keep=libname memname);
> by libname memname;
> prefix=substr(memname,2);
> if first.memname ;
> run;
>
> filename code temp;
> data _null_;
> set bigs;
> by prefix;
> file code ;
> if first.prefix then put "data &outlib..big_" prefix ';' / @3 'set' ;
> put +5 libname +(-1) '.' memname ;
> if last.prefix then put @3 ';' / 'run;' ;
> run;
> %inc code / source2;
>
> You can then wrap this up as a macro by replacing the %LET statements with a
> %macro statement with inlib and outlib as parameters.
>
> NOTE you will have trouble if the XX_... datasets do not have consistent
> structure.
>
> On Wed, 12 Oct 2011 14:36:35 +0000, abu zafar muyeen <muyeen70@HOTMAIL.COM>
> wrote:
>
> >Hi Tom,Yes, i had a question and i am new to this group and struggling to
> add question.Here is my question:
> >I want to create a macro which will append same type of dataset from a
> library into one big dataset and this marco will run every time there is a
> new study or any update. Like: datasets are AE_99_C_0158, AE_99_C_0159, ...
> AE_XX_C_XXXX, BS_99_C_0158, BS_99_C_0159,... BS_XX_C_XXXX. Now my
> intention to append all AE's into BIG_AE, all BS into BIG_BS etc.ThanksAbu
> >
> >> Date: Wed, 12 Oct 2011 09:22:14 -0400
> >> From: tom.abernathy@GMAIL.COM
> >> Subject: Re: Macro to add multiple SAS datasets into one big dataset by
> "append or set"
> >> To: SAS-L@LISTSERV.UGA.EDU
> >>
> >> The email system seems to removed all the whitespace from your post.
> >> Was there a question in there?
> >
|