Date: Tue, 13 Jul 2004 14:24:17 -0400
Reply-To: Jim Groeneveld <jim.groeneveld@VITATRON.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Jim Groeneveld <jim.groeneveld@VITATRON.COM>
Subject: Re: SAS Macro - merge
First of all you could throw out the inefficient DATA step:
and replace '&target' in your MERGE by 'contac'.
Furthermore you supply much too less info on what goes in and what goes
out. The macro seems to contain quite some seemingly unrelated variables
and code and I hardly see code related to your goal. Departing from your
input and output datasets I came to the following code (*untested*):
DATA Target; * (just a name, no macro code at all);
MERGE Contac Wave1 (IN=InWave1) Wave2 (IN=InWave2);
IF (InWave1) THEN Indid1 = Indid;
IF (InWave2) THEN Indid2 = Indid;
I hope this helps.
Regards - Jim.
On Tue, 13 Jul 2004 08:25:10 -0700, Wini <wottoy@ADVALVAS.BE> wrote:
>I have a problem with merging datasets within a macro. I would like to
>retain for each survey (in fact it are waves) the indid. Therefore I
>create indidX = indid. For a wave were the indid is present I would
>like to have that indid else a missing, but the only thing I get is a
>matrix with all indids. (it seemst that the value from the first
>datset, a list of all possible indids) is retained.
>The indid is called indid in all files, but I like to have a file with
>indid1 indid2 indi3
>suppose contac contains
>wave1 contains a datset with
>wave2 contains a datset with
>then I would like to have a dataset with
>indid indid1 indid2
>1111 . .
>1245 1245 1245
>2548 . 2548
>3655 3655 .
>What is wrong with this code?
>%do i=&iniw %to &endw;
>data &target(keep= indid &vars&iniw-&vars&i );
>merge &bib&i..w&i.&dsn &target ;
>Thanks in advance!