SAS中文论坛

 找回密码
 立即注册

扫一扫,访问微社区

查看: 710|回复: 1
打印 上一主题 下一主题

looking help for an effective summation approach

[复制链接]

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
楼主
 楼主| 发表于 2012-1-2 13:40:37 | 只看该作者

looking help for an effective summation approach

%let x1=2;
%let x2=9;
%let x3=0;
...
%let x50=11;

Suppose Xs above were generated into series of macro variables x1 - x50.
my question, what is the effective way to sum them up?
I tried:

%let sum_x=%sysfunc(&x1.,&x2.,...,&x50.);

but it looks pretty much stupid.
so just wonder anyone can help?

thanks lot and happy new year!
回复 支持 反对

使用道具 举报

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
沙发
 楼主| 发表于 2012-5-17 21:39:26 | 只看该作者

Re: looking help for an effective summation approach

%let x1=2;
%let x2=4;
%let x3=6;
%let x4=5;

%let s=0;

%macro summation;

%do i=1 %to 4;
    %let s=%eval(&s+&&x&i);
%end;
%put &s;

%mend;
%summation;
回复 支持 反对

使用道具 举报

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

本版积分规则

QQ|小黑屋|手机版|Archiver|SAS中文论坛  

GMT+8, 2025-5-6 12:54 , Processed in 0.069101 second(s), 20 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表