全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
1740 6
2014-12-05
悬赏 30 个论坛币 已解决

data a1 a2;
set a;
if d=4;
if da=&i then output a1;
if da=&j then output a2;
keep monthnum rfundeq dalpflag ;
run;


现在想把
if d=4;
if da=&i then output a1;
if da=&j then output a2

赋给cha

使得在宏中调用的时候能够用

data a1 a2;
set a;
&cha;
keep monthnum rfundeq dalpflag ;
run;



语法应该很多错了,仅仅表述个人意思




最佳答案

jl60156 查看完整内容

you could use macro %macro cha; if d=4; if da=&i then output a1; if da=&j then output a2 %mend cha; data a1 a2; set a; %cha; keep monthnum rfundeq dalpflag ; run;
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2014-12-5 10:52:39
you could use macro

%macro cha;
if d=4;
if da=&i then output a1;
if da=&j then output a2
%mend cha;

data a1 a2;
set a;
%cha;
keep monthnum rfundeq dalpflag ;
run;
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2014-12-5 11:35:59
jl60156 发表于 2014-12-5 11:24
you could use macro

%macro cha;
WARNING: 没有解析宏 CHA 的调用。
ERROR 180-322: 语句无效或未按正确顺序使用。
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2014-12-5 11:37:28
jl60156 发表于 2014-12-5 11:24
you could use macro

%macro cha;
哦    看错了   可以解析宏变量
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2014-12-5 11:40:37
jl60156 发表于 2014-12-5 11:24
you could use macro

%macro cha;
语句不能直接在data步中使用,却可以利用宏调用,挺神奇的
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2014-12-5 11:46:30
if you prefer &cha then you could try the following

%let cha=%QUOTE(
if d=4;
if da=&i then output a1;
if da=&j then output a2
);
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群