全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
3517 10
2013-01-28
我今天发现%do似乎必须要和%to联用。比如:
%macro a;
%do a=1,2,3; /*这样就不行*/
%put &a.;
%end;
%mend;
%a;

%macro a;
%do a=1 %to 3;  /*只能这样*/
%put &a.;
%end;
%mend;
%a;

现实的问题是,如果我想对a取1,3做循环,就比较麻烦了。我目前的解决办法是从1到3做循环,然后进来以后再用%if判断一下。谁有更好的办法?
二维码

扫码加我 拉你入群

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

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

全部回复
2013-1-28 21:58:40
%macro a;
%do a=1 %to 3 %by 2;
%put &a.;
%end;
%mend;
%a;

这样怎么样啊?我也不清楚macro里面是否一定要把%do和%to合用,不过看log是这么说的
二维码

扫码加我 拉你入群

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

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

2013-1-29 09:29:18
tangliang0905 发表于 2013-1-28 21:58
%macro a;
%do a=1 %to 3 %by 2;
%put &a.;
这样是对的。但是还不是我想要的,满足不了需求。
二维码

扫码加我 拉你入群

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

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

2013-1-29 09:35:14
You can alternative to set up a quote from i to theNumberUWant(i->N_i), say 1->3, 2->5, 3->7...... then use
%do i=1 %to 3;
       %put &&N_&i.;
%end;
二维码

扫码加我 拉你入群

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

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

2013-1-29 11:51:47
xiaodanzi 发表于 2013-1-29 09:35
You can alternative to set up a quote from i to theNumberUWant(i->N_i), say 1->3, 2->5, 3->7...... t ...
Yes, it is. It also a way I used to solve the problem, and it works. However, I think it is also a little troublesom and try to find a better way.
二维码

扫码加我 拉你入群

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

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

2013-1-29 11:51:50
xiaodanzi 发表于 2013-1-29 09:35
You can alternative to set up a quote from i to theNumberUWant(i->N_i), say 1->3, 2->5, 3->7...... t ...
Yes, it is. It also a way I used to solve the problem, and it works. However, I think it is also a little troublesom and try to find a better way.
二维码

扫码加我 拉你入群

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

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

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

说点什么

分享

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