我想计算不同产品类别中每个客户的销售总额差异。下面是一个例子。我收到了错误。请帮我说明如何才能一步到位。
ab - 客户 bc - 产品类别 bd - 金额
data a;
input ab$ bc$ bd;
datalines;
a x 5
a x 6
a y 9
a y 6
a y 5
a z 9
a z 8
b z 6
b z 9
b y 8
b y 6
b x 6
b x 6
b x 7
b z 8
b z 9
run;
proc sql;
create table b as select ab , var (sum_bd) from(
from (select ab, bc, sum(bd) as sum_bd from a group by ab, bc))
group by ab;
run;
答案 0 :(得分:0)
您有两个from
条款。试试这个语法正确的版本:
proc sql;
create table b as
select ab, var(sum_bd)
from (select ab, bc, sum(bd) as sum_bd
from a
group by ab, bc
) a
group by ab;
run;
答案 1 :(得分:0)
MySQL中没有VAR函数,它是VAR_POP或VAR_SAMP。