Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 计算年末列总数_Sql_Sas - Fatal编程技术网

Sql 计算年末列总数

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

我在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=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摘要统计”