楼主: silentzilch
1314 9

[有偿编程] 求 SAS macro 高手! [推广有奖]

  • 1关注
  • 0粉丝

大专生

5%

还不是VIP/贵宾

-

威望
0
论坛币
143 个
通用积分
1.0500
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
396 点
帖子
15
精华
0
在线时间
64 小时
注册时间
2015-1-15
最后登录
2025-5-14

楼主
silentzilch 发表于 2015-4-9 10:30:46 |AI写论文
500论坛币

1.jpg (90.2 KB)

1.jpg

1.jpg (10.48 KB)

1.jpg

最佳答案

pobel 查看完整内容

%macro test(list=); %let n=%eval(%sysfunc(count(&list,%str( )))+1); data test; array v {&n}; array tmp {&n} _temporary_ (&list); do i=1 to &n; do j=1 to &n; v(j)=tmp(abs(j-i)+1); end; output; end; drop i j; run; %mend; %test(list=16 8 4 2) %test(list=4 8 12 900 88) %test(list=1 2 3 4 5 6 7)
关键词:Macro acr CRO Mac

沙发
pobel 在职认证  发表于 2015-4-9 10:30:47
silentzilch 发表于 2015-4-10 02:22
感谢您的回答!
但是我想实现的是输入任意一串数据然后进行排列的macro,而非单纯实现例子中的矩阵,还请 ...
%macro test(list=);
   %let n=%eval(%sysfunc(count(&list,%str( )))+1);

   data test;
       array v {&n};
           array tmp {&n} _temporary_ (&list);
           do i=1 to &n;
              do j=1 to &n;
                     v(j)=tmp(abs(j-i)+1);
                  end;
                 output;
            end;
                drop i j;
        run;
%mend;
%test(list=16 8 4 2)
%test(list=4 8 12 900 88)
%test(list=1 2 3 4 5 6 7)

藤椅
pobel 在职认证  发表于 2015-4-9 12:45:13
%let n=4;
data test;
   array v(&n);
   do i=1 to &n;
      do j=1 to &n;
              v(j)=2**(&n-abs(j-i));
      end;
          output;
   end;
   drop i j;
run;

板凳
learsaas 发表于 2015-4-9 15:26:12
proc iml;
        n=4;
        A=toeplitz(2##(n:1));
        print A;
quit;

报纸
sushe1527 发表于 2015-4-9 15:57:24
learsaas 发表于 2015-4-9 15:26
proc iml;
        n=4;
        A=toeplitz(2##(n:1));
吊炸天

地板
silentzilch 发表于 2015-4-10 02:22:26
pobel 发表于 2015-4-9 12:45
%let n=4;
data test;
   array v(&n);
感谢您的回答!
但是我想实现的是输入任意一串数据然后进行排列的macro,而非单纯实现例子中的矩阵,还请指教!

7
silentzilch 发表于 2015-4-10 02:23:52
learsaas 发表于 2015-4-9 15:26
proc iml;
        n=4;
        A=toeplitz(2##(n:1));
PROC IML 我也想过,但我的目标是生成一个data set.
谢谢回答。

8
silentzilch 发表于 2015-4-10 10:25:05
pobel 发表于 2015-4-9 10:30
%macro test(list=);
   %let n=%eval(%sysfunc(count(&list,%str( )))+1);
感谢您的回答!还有一个macro问题也在悬赏求解 https://bbs.pinggu.org/thread-3654300-1-1.html
如果有空,请您赐教。

9
learsaas 发表于 2015-4-10 11:26:55
silentzilch 发表于 2015-4-10 02:23
PROC IML 我也想过,但我的目标是生成一个data set.
谢谢回答。
iml也可以输出到dataset,个人觉得关于矩阵的问题还是用iml比较合适

10
huala777 发表于 2015-4-12 11:54:43
IML绝对是事半功倍,强用macro无非多此一举。

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

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2026-1-29 16:36