2017-05-04 77 views
-2

我在SAS的数据集,其具有列如下所示:计算年末柱总

日期:该字段的格式是“15Dec2014” 金额:例如20000

我需要计算年终总额总计。因此在特定的一年中,总额为2014年12月31日。我最终希望将每年的最终总计存储在单独的数据集中。有任何想法吗?

+0

这不是一个代码编写的服务,请发表你已经尝试了什么。这是一个PROC MEANS或PROC SQL,应该是直截了当的,尝试使用Google搜索“SAS汇总统计” – Reeza

回答

0

试试这个: -

/*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; 

希望这有助于:-)