SAS中文论坛

标题: 我是新手,请各位帮忙,万分感谢! [打印本页]

作者: shiyiming    时间: 2006-4-7 11:41
标题: 我是新手,请各位帮忙,万分感谢!
我是个SAS新手,现在需要一个程序,请好心人帮助,在这里先谢谢各位了!
题名:
有180种植物(spec1-spec180)的省份分布(prov)、气候参数(temp,como,wamo,ffd,rain),现在根据每种植物的现有分布情况,推断其可能扩散的分布省份。
prov    temp   como  wamo  ffd  rain  spec1  spec2  spec3  spec4  spec5...
Anhui  15.5     2         28    225  1225   1        0          0       0         1
Beijing 11       7.5      25    180        600    1        0          0       0         0
Fujian  18.5     9       28.5  275  1500    0        1          0       0         0
Gansu   7       -6       23     180   425    0        0          1       0         1
Guangdong23  12      28    322   1550   0        1          1       0         0
Guangxi 20   10.5      27    315   1750   0        1          0       0         0
Guizhou  15     9        24    270   1250   1        0          0       1         0
Hainan    24   18.5     27    360   1750   0         1         0       1         0
...           ...    ...        ...    ...       ...      ...      ...        ...      ...        ...

其中“1”代表已分布,“0”代表未分布,现在以spec1为例,它现在Anhui、 Beijing、Guizhou有分布,求这些现有分布地区的气候极值,即temp、como、 wamo、 ffd、rain的MAX和MIN值,

If species=1,计算:
maxtemp=max(temp) and
mintemp=min(temp) and
maxcomo=max(como) and
mincomo=min(como) and
maxwamo=max(wamo) and
minwamo=min(wamo) and
maxffd=max(ffd) and
minffd=min(ffd) and
maxrain=max(rain) and
minrain=min(rain)
;并输出结果,标明“spec1的现有分布”。
第二步计算可能的分布区,即
if temp>=mintemp and temp<=maxtemp and
coldmo>=mincomo and coldmo<=maxcomo and
warmmo>=minwamo and warmmo<=maxwamo and
ffdays>=minffd and ffdays<=maxffd and
rain>=minrain and rain<=maxrain

最后输出结果,表明“spec1的可能分布”。

我已经苦想一个多月了,学了n多Sas入门之类的书籍,就是编不出来,请高手帮忙,再次谢谢了!
作者: shiyiming    时间: 2006-4-13 03:17
标题: summary
If I understand your question well, here is code for each of 180种植物(spec1-spec180).

proc sql;
create spec1 as
select prov, temp ,como ,wamo ,ffd ,rain ,spec1
from datasetname
where spec1=1 and
min(temp) <= temp <=max(temp) and
min(como) <= coldmo<=max(como) and
min(wamo) <= warmmo<=max(wamo) and
min(ffd) <= ffdays <=max(ffd) and
min(rain)<= rain<=max(rain);
quit;
作者: shiyiming    时间: 2006-4-13 09:25
标题: zzz
proc sql;
create table spec1 as
select prov, temp ,como ,wamo ,ffd ,rain ,spec1
from datasetname
where spec1=1
having  min(temp) <= temp <=max(temp) and
min(como) <= como<=max(como) and
min(wamo) <= wamo<=max(wamo) and
min(ffd) <= ffd <=max(ffd) and
min(rain)<= rain<=max(rain);
quit;
作者: shiyiming    时间: 2006-4-14 12:15
标题: 感谢大家!
非常感谢大家的帮忙,
我经过大家的帮助和刻苦学习,已经解决了问题,再次对大家的关怀与帮助表示感谢!
作者: shiyiming    时间: 2006-4-15 23:32
标题: 请问?
。。。
having min(temp) <= temp <=max(temp) and
min(como) <= como<=max(como) and
min(wamo) <= wamo<=max(wamo) and
min(ffd) <= ffd <=max(ffd) and
min(rain)<= rain<=max(rain);
。。。
is there any possiblity that temp would be less than min(tem) or greater max(temp)? if not, "having clasue" is necessary?




欢迎光临 SAS中文论坛 (http://mysas.net/forum/) Powered by Discuz! X3.2