Date: Tue, 13 Jul 2004 08:25:10 -0700
Reply-To: Wini <wottoy@ADVALVAS.BE>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Wini <wottoy@ADVALVAS.BE>
Organization: http://groups.google.com
Subject: SAS Macro - merge
Content-Type: text/plain; charset=ISO-8859-1
Hi,
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
indid
1111
1245
2548
3655
wave1 contains a datset with
indid
1245
3655
wave2 contains a datset with
1245
2548
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?
%macro comb(bib,dsn,iniw,endw,sortvar,target,vars);
data ⌖
set contac;
run;
%do i=&iniw %to &endw;
data &target(keep= indid &vars&iniw-&vars&i );
merge &bib&i..w&i.&dsn &target ;
by &sortvar;
&vars.&i=indid;
run;
%end;
%mend;
%comb(wave,adult,1,3,indid,test,indid);
Thanks in advance!
|