楼主: chenys625
3025 10

%do的问题 [推广有奖]

  • 0关注
  • 2粉丝

硕士生

34%

还不是VIP/贵宾

-

威望
0
论坛币
53 个
通用积分
0
学术水平
32 点
热心指数
29 点
信用等级
26 点
经验
2400 点
帖子
176
精华
0
在线时间
123 小时
注册时间
2012-1-17
最后登录
2019-11-25

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
我今天发现%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判断一下。谁有更好的办法?
二维码

扫码加我 拉你入群

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

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

关键词:Macro 解决办法 End acr CRO

本帖被以下文库推荐

沙发
tangliang0905 发表于 2013-1-28 21:58:40 |只看作者 |坛友微信交流群
%macro a;
%do a=1 %to 3 %by 2;
%put &a.;
%end;
%mend;
%a;

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

使用道具

藤椅
chenys625 发表于 2013-1-29 09:29:18 |只看作者 |坛友微信交流群
tangliang0905 发表于 2013-1-28 21:58
%macro a;
%do a=1 %to 3 %by 2;
%put &a.;
这样是对的。但是还不是我想要的,满足不了需求。

使用道具

板凳
xiaodanzi 发表于 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;
已有 1 人评分学术水平 热心指数 信用等级 收起 理由
chenys625 + 1 + 1 + 1 我很赞同

总评分: 学术水平 + 1  热心指数 + 1  信用等级 + 1   查看全部评分

使用道具

报纸
chenys625 发表于 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.

使用道具

地板
chenys625 发表于 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.

使用道具

7
chenys625 发表于 2013-1-29 11:52:22 |只看作者 |坛友微信交流群
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.

使用道具

8
bjtoronto 发表于 2013-1-29 22:47:34 |只看作者 |坛友微信交流群
Try the following, let me know any concerns.

%macro looptest / parmbuff;
%let loopindex=1;
%do %until (%scan(&syspbuff,&loopindex) eq );
        %let loopnum=%scan(&syspbuff,&loopindex);
        %if &loopnum ne %then
                %put &loopnum;
        %else
                %put ***Wrong!!!***;
        %let loopindex=%eval(&loopindex+1);
%end;
%mend;

%looptest(3 5 10)
已有 3 人评分论坛币 学术水平 热心指数 信用等级 收起 理由
rdwalk + 1 + 1 + 1 beautifullllllllllllllllllllllllllllllll
admin + 100 热心帮助其他会员
chenys625 + 1 + 1 + 1 观点有启发

总评分: 论坛币 + 100  学术水平 + 2  热心指数 + 2  信用等级 + 2   查看全部评分

使用道具

9
bjtoronto 发表于 2013-1-29 22:59:26 |只看作者 |坛友微信交流群

使用道具

10
chenys625 发表于 2013-1-30 10:04:24 |只看作者 |坛友微信交流群
bjtoronto 发表于 2013-1-29 22:47
Try the following, let me know any concerns.

%macro looptest / parmbuff;
用loopnum做所列宏的指标,然后学习想到用%scan函数,精彩!
/ parmbuff 和 &syspbuff 也是我以前没用过的,学习了不少! 谢谢

使用道具

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

本版微信群
加好友,备注cda
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-4-28 02:21