楼主: shuiqq19840621
11363 9

数组的定义 [推广有奖]

  • 0关注
  • 0粉丝

大专生

48%

还不是VIP/贵宾

-

威望
0
论坛币
108 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
308 点
帖子
46
精华
0
在线时间
29 小时
注册时间
2009-9-3
最后登录
2009-12-9

楼主
shuiqq19840621 发表于 2009-9-19 12:55:53 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
比如说要把下面一组观测值用数组表示出来,该用哪个命令啊?
数组如下:
1 2 2 3 3 46436 452352 52345
这个八个数,如何把他们表示成c1,c2,一直到c8,就是把这八个弄成一个数组.
还有就是如果数据比较多,表示成一个数据集后如何调用出来并表示成数组.
比如说数据集表示在如下:
data bonds040927(label='2004年9月27日上交所22只付息国债收盘价');
input bdname $8. matdt:yymmdd10. freq coupond Cldirpr dur term@;
format matdt yymmdd10.;
label
bdname='债券名称'
matdt='到期日'
freq='年付息频率'
coupond='票面利息'
Cldirpr='市场价格'
dur='久期'
term='年限';
cards;
96国债6  2006-6-14   1 11.83   114.85  1.90262 10
97国债4  2007-9-5    1 9.78    116.6   2.76666 10
99国债5  2007-8-20   1 3.28    98.48   2.9076  8
99国债8  2009-9-23   1 3.3     94.62   4.70122 10
21国债3  2008-4-24   1 3.27    96.66   3.81898 7
21国债7  2021-7-31   2 4.26    92.09   12.9768 20
21国债10 2011-9-25   1 2.95    89.13   6.44658 10
21国债12 2011-10-30  1 3.05    89.67   7.25293 10
21国债15 2008-12-18  1 3       94.16   4.72472 7
02国债3  2012-4-18   1 2.54    86      7.3555  10
02国债10 2009-8-16   1 2.39    90.71   4.77451 7
02国债13 2017-9-20   2 2.6     77.36   11.1914 15
02国债14 2007-10-24  1 2.65    95.96   3.84993 5
02国债15 2009-12-6   1 2.93    92.5    5.60126 7
03国债11 2010-2-19   1 2.66    90.65   5.63273 7
03国债3  2023-4-17   2 3.4     80.64   14.6887 20
03国债7  2010-8-20   1 2.66    89.69   5.63273 7
03国债8  2013-9-17   1 3.02    87.26   8.06064 10
03国债11 2010-11-19  1 3.5     93.7    6.36469 7
04国债3  2009-4-19   1 4.4164  99.92   4.61904 5
04国债4  2011-5-25   1 4.89    101.04  6.17962 7
04国债7  2011-8-25   1 4.71    99.97   6.20199 7
要把其中的市场价格定为一个数组,该怎么引用啊?
二维码

扫码加我 拉你入群

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

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

关键词:coupon format label FORMA Input 定义

回帖推荐

bobguy 发表于10楼  查看完整内容

I have never heard about PROC GA and honestly, I don’t know how this PROC deals with ARRAY. .. [/quote] Me too. But here is the documentation link, http://support.sas.com/documentation/cdl/en/orlsoug/59688/HTML/default/ga_sect1.htm Overview: GA Procedure Genetic algorithms are a family of local search algorithms that seek optimal solutions to problems by applying the principles of na ...

nkwilling 发表于3楼  查看完整内容

在SAS里面,数组是用来表示变量的,不是用来表示变量的值。你的提法本身就有点问题,当然,通过转置可以表示数组,但鲜有这样做的,主要原因是可能需要面对massive级别的数据。还有,在SAS里面,数组一般是和DO循环语句连用的,你一定要多看SAS HELP文档,SAS很多基本的问题你都可以其文档里面找到。

本帖被以下文库推荐

沙发
xiaosanmao 发表于 2009-9-19 13:54:59
proc sql;
select cldirpr  into: index from bonds040927;
quit;

然后用 &index 就可以调用 cldirpr 了

藤椅
nkwilling 发表于 2009-9-20 09:49:56
在SAS里面,数组是用来表示变量的,不是用来表示变量的值。你的提法本身就有点问题,当然,通过转置可以表示数组,但鲜有这样做的,主要原因是可能需要面对massive级别的数据。还有,在SAS里面,数组一般是和DO循环语句连用的,你一定要多看SAS HELP文档,SAS很多基本的问题你都可以其文档里面找到。
已有 1 人评分经验 论坛币 收起 理由
bakoll + 3 + 3 精彩帖子

总评分: 经验 + 3  论坛币 + 3   查看全部评分

板凳
shuiqq19840621 发表于 2009-9-20 10:49:40
谢谢指导! 3# nkwilling

报纸
shuiqq19840621 发表于 2009-9-20 10:51:31
能否说详细一点啊,怎么调用? 2# xiaosanmao

地板
shuiqq19840621 发表于 2009-9-20 10:54:17
我现在的问题是要做一个遗传算法,我给出部分程序.
proc ga seed=5555 maxiter = 30;
function y(selected[*]);
array x[6] /nosym;
call ReadMember(selected,1,x);
x1=x[1];
x2=x[2];
x3=x[3];
x4=x[4];
x5=x[5];
x6=x[6];
set float_time;
sum1[j]=0;
do i=1 to 38;
sum1[j]=sum1[j]+c[i]*exp(-t[i]*(x1+(x2+x3)*((1-exp(-t[i]/x5))/(t[i]/x5)-x3*ex(-t[i]/x5)+x4*((1-exp(-t[i]/x6))/(t[i]/x6)-exp(-t[i]/x6)));
end;
sum2=0;
do j=1 to 22;
sum2=sum2+(p[j]-sum1[j])**2*w[j];
end;
result=sum2;
      return(result);
   endsub;
call SetEncoding('R2');
array LowerBound[6] /nosym (0.086 -0.086 -0.109 0.042 9 2.2);
array UpperBound[6] /nosym (0.094 -0.076 -0.098 0.054 12 4);
call SetBounds(LowerBound, UpperBound);
call SetObjFunc('y',0);
call SetCrossProb(0.65);
call SetCrossHeuristic();
call SetMutProb(0.15);
array delta[2] /nosym (0.2 0.2);
call SetMutDelta(delta, 1);
call SetSelTournament(2);
call SetElite(2);
call Initialize('DEFAULT',120);
run;
quit;
其中的p[j]和w[j]要在其他数据表中按顺序使用,这一部应该怎么做?麻烦再指点一下!

7
wyxlls725 发表于 2009-12-30 13:23:45
SAS数组还真没有研究过,学习一下!

8
cz851218 发表于 2010-3-17 20:00:22
认真学习。。。

9
jingju11 发表于 2010-3-17 21:57:50
shuiqq19840621 发表于 2009-9-20 10:54
我现在的问题是要做一个遗传算法,我给出部分程序.
proc ga seed=5555 maxiter = 30;
function y(selected );
array x[6] /nosym;
call ReadMember(selected,1,x);
x1=x[1];
x2=x[2];
x3=x[3];
x4=x[4];
x5=x[5];
x6=x[6];
set float_time;
sum1[j]=0;
do i=1 to 38;
sum1[j]=sum1[j]+c*exp(-t*(x1+(x2+x3)*((1-exp(-t/x5))/(t/x5)-x3*ex(-t/x5)+x4*((1-exp(-t/x6))/(t/x6)-exp(-t/x6)));
end;
sum2=0;
do j=1 to 22;
sum2=sum2+(p[j]-sum1[j])**2*w[j];
end;
result=sum2;
      return(result);
   endsub;
call SetEncoding('R2');
array LowerBound[6] /nosym (0.086 -0.086 -0.109 0.042 9 2.2);
array UpperBound[6] /nosym (0.094 -0.076 -0.098 0.054 12 4);
call SetBounds(LowerBound, UpperBound);
call SetObjFunc('y',0);
call SetCrossProb(0.65);
call SetCrossHeuristic();
call SetMutProb(0.15);
array delta[2] /nosym (0.2 0.2);
call SetMutDelta(delta, 1);
call SetSelTournament(2);
call SetElite(2);
call Initialize('DEFAULT',120);
run;
quit;
其中的p[j]和w[j]要在其他数据表中按顺序使用,这一部应该怎么做?麻烦再指点一下!

I have never heard about PROC GA and honestly, I don’t know how this PROC deals with ARRAY. ..

10
bobguy 发表于 2010-3-18 08:09:51
jingju11 发表于 2010-3-17 21:57
shuiqq19840621 发表于 2009-9-20 10:54
我现在的问题是要做一个遗传算法,我给出部分程序.
proc ga seed=5555 maxiter = 30;
function y(selected );
array x[6] /nosym;
call ReadMember(selected,1,x);
x1=x[1];
x2=x[2];
x3=x[3];
x4=x[4];
x5=x[5];
x6=x[6];
set float_time;
sum1[j]=0;
do i=1 to 38;
sum1[j]=sum1[j]+c*exp(-t*(x1+(x2+x3)*((1-exp(-t/x5))/(t/x5)-x3*ex(-t/x5)+x4*((1-exp(-t/x6))/(t/x6)-exp(-t/x6)));
end;
sum2=0;
do j=1 to 22;
sum2=sum2+(p[j]-sum1[j])**2*w[j];
end;
result=sum2;
      return(result);
   endsub;
call SetEncoding('R2');
array LowerBound[6] /nosym (0.086 -0.086 -0.109 0.042 9 2.2);
array UpperBound[6] /nosym (0.094 -0.076 -0.098 0.054 12 4);
call SetBounds(LowerBound, UpperBound);
call SetObjFunc('y',0);
call SetCrossProb(0.65);
call SetCrossHeuristic();
call SetMutProb(0.15);
array delta[2] /nosym (0.2 0.2);
call SetMutDelta(delta, 1);
call SetSelTournament(2);
call SetElite(2);
call Initialize('DEFAULT',120);
run;
quit;
其中的p[j]和w[j]要在其他数据表中按顺序使用,这一部应该怎么做?麻烦再指点一下!

I have never heard about PROC GA and honestly, I don’t know how this PROC deals with ARRAY. ..
Me too. But here is the documentation link,

http://support.sas.com/documentation/cdl/en/orlsoug/59688/HTML/default/ga_sect1.htm

Overview: GA Procedure
Genetic algorithms are a family of local search algorithms that seek  optimal solutions to problems by applying the principles of natural  selection and evolution. Genetic algorithms can be applied to almost  any optimization problem and are especially useful for problems where  other calculus-based techniques do not work, such as when the  objective function has many local optima, when it is not differentiable or  continuous, or when solution elements are constrained to be integers or  sequences. In most cases genetic algorithms require more computation  than specialized techniques that take advantage of specific problem  structures or characteristics. However, for optimization problems with  no such techniques available, genetic algorithms provide a robust  general method of solution.
已有 1 人评分经验 论坛币 收起 理由
bakoll + 3 + 3 精彩帖子

总评分: 经验 + 3  论坛币 + 3   查看全部评分

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

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