| 
 | 
楼主
 
 
 楼主 |
发表于 2013-7-31 01:35:54
|
只看该作者
 
 
 
need a help for a macro code
%let dc1=('a1','a11'); 
%let dc2=('a12','a22'); 
%let dc3=('a13','a23');         
%let dcl1=lbl_dc1; 
%let dcl2=lbl_dc2; 
%let dcl3=lbl_dc3; 
data a; 
input dx1 $ dx2 $ dx3 $ dx4 $ dx5 $ dx6; 
cards; 
a51 a27 a3 a1 a5 a16  
a12 a33 a6 a15 a32 a10 
. . . 
; 
run; 
 
%macro dc; 
data b; set a; 
 array adx(6) dx1-dx6; 
  %do i= 1 %to 6; 
   %do j=1 %to 3; 
   if adx(&i.) in &&dc&j. then do;flag="&&dc&j."; lbl="&&dcl&j."; end; 
   %end; 
 %end; 
%mend; 
%dc 
 
what I want: 
 if dx1-dx6 in data A(1M obs) has the same value with dc1-dc3, then add two more variables:flag and lbl (they are defined in the code), if not, leave blank. please see table below:  
dx1 $ dx2 $ dx3 $ dx4 $ dx5 $ dx6 $ flag  lbl; 
a51    a27    a3     a1      a5    a16    dc1    lbl_dc1 
a12  a33   a6    a15     a32   a10     dc2    lbl_dc2 
. . .  
 
the code above gave me ERROR and just wonder anyone please help me to figure out the problem or a different solution. 
thanks!!! |   
 
 
 
 |