楼主: chenchengzhi22
1707 2

[问答] call symput的问题 [推广有奖]

  • 0关注
  • 1粉丝

硕士生

87%

还不是VIP/贵宾

-

威望
0
论坛币
55 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
1889 点
帖子
126
精华
0
在线时间
225 小时
注册时间
2010-5-14
最后登录
2023-9-1

楼主
chenchengzhi22 发表于 2014-1-3 02:09:30 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
data _caldates; set _caldates;
    n+1;
    if intnx('month',beg_date,0,'e')=
    intnx('month',"&mindate"d,0,'e') then call symput ('start',n);
    if intnx('month',end_date,0,'e')=
    intnx('month',"&maxdate"d,0,'e') then call symput ('finish',n);
  run;

  %do j=&start %to &finish %by &step;

   data _null_; set _caldates (sortedby=n where=(n=&j));
    call symput ('beg',beg_date);
   run;

  data _null_; set _caldates (sortedby=n where=(n=&j));
  call symput ('end',end_date);
   run;

   data _sample/view=_sample;
     do k=1 by 1 until (last.permno);
      set _vol; by permno;
      where &beg<=date<&end;
      if missing(ret) then continue;
      mcount=sum(mcount,1);
    end;
   keep permno mcount;
   run;

这段程序为什么用call symput 定义的 start finish beg和end好像不工作那?谢谢各位帮助

二维码

扫码加我 拉你入群

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

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

关键词:symput call put finish Sample where start null

沙发
heperwong 在职认证  发表于 2014-1-3 09:31:55
兄弟,%do j=&start %to &finish %by &step; 后面的这两段是要放进宏里面的,帮你改一下吧。
  1. options symbolgen mlogic;
  2. %macro dd(step=);
  3. %global &beg &end;
  4.   %do j=&start %to &finish %by &step;
  5.    data _null_;
  6. set _caldates (sortedby=n where=(n=&j));
  7.     call symput ('beg',beg_date);
  8.    run;
  9.   data _null_;
  10. set _caldates (sortedby=n where=(n=&j));
  11.   call symput ('end',end_date);
  12.    run;
  13. %end;
  14. %mend;
  15. %dd(step=5);
复制代码
已有 2 人评分经验 论坛币 学术水平 热心指数 信用等级 收起 理由
chenchengzhi22 + 1 + 1 + 1 精彩帖子
webgu + 60 + 40 对头。

总评分: 经验 + 60  论坛币 + 40  学术水平 + 1  热心指数 + 1  信用等级 + 1   查看全部评分

藤椅
chenchengzhi22 发表于 2014-1-3 13:59:25
heperwong 发表于 2014-1-3 09:31
兄弟,%do j=&start %to &finish %by &step; 后面的这两段是要放进宏里面的,帮你改一下吧。
谢谢热心帮助,改过以后可以跑了:)

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

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-30 01:53