Sql 计算年末列总数
我在SAS中有一个数据集,其列如下: 日期:此字段的格式为“2014年12月15日” 金额:例如20000 我需要计算年终总结。因此,对于某一特定年份,截至2014年12月31日的总金额。我最终希望将每年的年终总计存储在一个单独的数据集中。有什么想法吗?试试这个:-Sql 计算年末列总数,sql,sas,Sql,Sas,我在SAS中有一个数据集,其列如下: 日期:此字段的格式为“2014年12月15日” 金额:例如20000 我需要计算年终总结。因此,对于某一特定年份,截至2014年12月31日的总金额。我最终希望将每年的年终总计存储在一个单独的数据集中。有什么想法吗?试试这个:- /*For each date in a year, 'INTNX' will give you the year end date*/ Data answer; set your_sas_dataset; year_end=pu
/*For each date in a year, 'INTNX' will give you the year end date*/
Data answer;
set your_sas_dataset;
year_end=put(intnx('year ', Date , 0, 'e'),date9.);
run;
/*Summing amount on the year end dates will give us the totals for a particular year as of 31st December*/
Proc sql;
Select year_end, sum(Amount) as year_end_totals
from
answer
group by year_end;
quit;
希望这有帮助:-)这不是一项代码编写服务,请发布您尝试过的内容。这是一个简单的PROC-MEANS或PROC-SQL,试试谷歌搜索“SAS摘要统计”