| Date: | Sun, 14 Jan 2007 23:25:18 -0800 |
| Reply-To: | David L Cassell <davidlcassell@MSN.COM> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | David L Cassell <davidlcassell@MSN.COM> |
| Subject: | Re: Help with reusable Merge macro |
| In-Reply-To: | <1168563174.567934.87010@s34g2000cwa.googlegroups.com> |
| Content-Type: | text/plain; format=flowed |
|---|
webonomic@GMAIL.COM wrote:
>
>First question. In my Log, is there not a way to display the output of
>macros instead of seeing the ¯oname.
>Ie. If I did %let jane = 0; My log would show &jane but I want it to
>show 0.
>
>
>Second question:
>I am running the following code:
>
>%INCLUDE "C:\constants.sas";
>%let data1 = a.&survey1; /* a is a libname in constants, as is the
>survey1 and survey2 */
>&let data2 = a.&survey2;
>%merge_loc(ds1=&data1, ds2=&data2, resultdataset=d);
>
>
>
>The macro merge_loc is in the constants.sas file and looks like this:
>
>%MACRO merge_loc(ds1=, ds2=, resultdataset=);
>
> proc sort data=&ds1;
> by Site;
> run;
>
> proc sort data=&ds2;
> by Site;
> run;
>
> data &resultdataset;
> merge &ds1 &ds2;
> by Site;
> run;
>
>%MEND merge_loc;
>
>
>I know the actual code within the merge_loc works. It's something
>about all the macros which isn't working. Anyone spot any mistakes?
>
>My ultimate goal here is to create a reusable Merge macro.
First, I think you should look into the macro options
MPRINT
SYMBOLGEN
MLOGIC
You don't need all of them, and just having one (say, MPRINT)
ought to be enough for your macro code to show up properly
in the log.
But I don't think this is the way to do a 'merge' macro. You
have chosen the slowest way to do a merge, and it is a way which
does not work properly under a lot of conditions (for example:
SITE=42 shows up more than once in both input data sets;
or SITE takes on rational values like 41.993 which might be
messed up by roundoff errors if SITE is stored in less than 8 bytes
in one of the data sets; or SITE is a character variable and its
length differs between data sets; or ...)
So I would seriously look into alternatives for merging. If you
are writing a 'merge' macro, you should really look into the
database management issues.
WHY do you need to merge here?
How big are the tables going to get?
Are there any duplicates values of the merge key?
How many variables are you passing form the satellite data set?
What questions have I forgotten to ask at this hour?
HTH,
David
--
David L. Cassell
mathematical statistician
Design Pathways
3115 NW Norwood Pl.
Corvallis OR 97330
_________________________________________________________________
Get FREE Web site and company branded e-mail from Microsoft Office Live
http://clk.atdmt.com/MRT/go/mcrssaub0050001411mrt/direct/01/
|