SAS中文论坛

 找回密码
 立即注册

扫一扫,访问微社区

查看: 1541|回复: 1
打印 上一主题 下一主题

need a help for a macro code

[复制链接]

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
楼主
 楼主| 发表于 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!!!
回复 支持 反对

使用道具 举报

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
沙发
 楼主| 发表于 2013-7-31 04:22:13 | 只看该作者

Re: need a help for a macro code

shame on myself. I missed 'run;'. sorry.
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|手机版|Archiver|SAS中文论坛  

GMT+8, 2025-5-2 09:12 , Processed in 0.079789 second(s), 21 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表