在 SAS 中添加两行
Adding two rows in SAS
我有一个名为 A 的 table,我想创建一个新的 table,它具有相同的值,但在 table 的末尾,另一行称为“总计” ,进行以下计算:
(A+BB+ES)-(BD+L+S).
基本上,我想要的 table 与所附屏幕截图中的相同,但添加了一个名为 Total 的行,其值为“32”,来自 (A+BB+ES)- (BD+L+S).
到目前为止我的代码如下:
proc sql;
create table A as select 'Total' as Name from A
union
select * from A;
quit
以下是否符合预期?
select name, count
from A
union all
select 'Total',
Sum(case when name in ('a','bb','es') then count end)
-Sum(case when name in ('bd','l','s') then count end)
from A
我有一个名为 A 的 table,我想创建一个新的 table,它具有相同的值,但在 table 的末尾,另一行称为“总计” ,进行以下计算:
(A+BB+ES)-(BD+L+S).
基本上,我想要的 table 与所附屏幕截图中的相同,但添加了一个名为 Total 的行,其值为“32”,来自 (A+BB+ES)- (BD+L+S).
到目前为止我的代码如下:
proc sql;
create table A as select 'Total' as Name from A
union
select * from A;
quit
以下是否符合预期?
select name, count
from A
union all
select 'Total',
Sum(case when name in ('a','bb','es') then count end)
-Sum(case when name in ('bd','l','s') then count end)
from A