SAS中文论坛

标题: 如何SQL 简化计算 [打印本页]

作者: shiyiming    时间: 2010-5-3 15:07
标题: 如何SQL 简化计算
请问如下程序 可以怎么简化计算啊
proc sql noprint;
create table hind1 as
select distinct stkcd, dt,  sum(stakeQ*stakeQ) as Hind1
     from yyy
where Acquchrct in (1,2,3,6,7)
group by  stkcd;
quit;

proc sql noprint;
create table hind2 as
select distinct stkcd, dt, sum(stakeQ*stakeQ) as Hind2
from yyy
where Acquchrct in (4,5,8,9)
group by  stkcd;
quit;

proc sql noprint;
create table hind3 as
select distinct stkcd, dt, sum(stakeQ*stakeQ) as Hind3
from yyy
where Acquchrct in (13,12,14,16,17)
group by  stkcd;
quit;

proc sql noprint;
create table hind4 as
select distinct stkcd, dt, sum(stakeQ*stakeQ) as Hind4
from yyy
where Acquchrct in (23,22,24,26,27)
group by  stkcd;
quit;

data hind;
merge hind1-hind4;
run;
作者: shiyiming    时间: 2010-5-4 18:48
标题: Re: 如何SQL 简化计算
不清楚你的Acquchrct 是否比较复杂,建议你另建一个分组的标识,再做相关计算,不知道是不是你所说的简化计算 <!-- s:shock: --><img src="{SMILIES_PATH}/icon_eek.gif" alt=":shock:" title="Shocked" /><!-- s:shock: -->

if Acquchrct in (1,2,3,6,7) then mark=1;else ...




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