全部版块 我的主页
论坛 休闲区 十二区 灌水吧
522 1
2018-01-15

现在有如下数据截图
原始数据
希望得到
效果图

其实在excel中就是一个pivot table就解决了,请问用sas应该怎么解决?





二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2018-1-15 16:22:49
我使用的是静态sql的方式实现了,但是非常麻烦,sas是否有更简单的方法?

proc sql;
create table client_yy as
select client_y.ttt,  
  sum(case when client_y.year= 'FY2015' then account3 else 0 end) as z20151,
  sum(case when client_y.year= 'FY2015' then account4 else 0 end) as z20152,  
  sum(case when client_y.year= 'FY2015' then amount1 else 0 end) as z20153,  
  sum(case when client_y.year= 'FY2015' then amount2 else 0 end) as z20154,  
  sum(case when client_y.year= 'FY2016' then account3 else 0 end) as z20161,
  sum(case when client_y.year= 'FY2016' then account4 else 0 end) as z20162,  
  sum(case when client_y.year= 'FY2016' then amount1 else 0 end) as z20163,  
  sum(case when client_y.year= 'FY2016' then amount2 else 0 end) as z20164,
  sum(case when client_y.year= 'FY2017' then account3 else 0 end) as z20171,
  sum(case when client_y.year= 'FY2017' then account4 else 0 end) as z20172,  
  sum(case when client_y.year= 'FY2017' then amount1 else 0 end) as z20173,  
  sum(case when client_y.year= 'FY2017' then amount2 else 0 end) as z20174,
  sum(case when client_y.year= 'FY2018' then account3 else 0 end) as z20181,
  sum(case when client_y.year= 'FY2018' then account4 else 0 end) as z20182,  
  sum(case when client_y.year= 'FY2018' then amount1 else 0 end) as z20183,  
  sum(case when client_y.year= 'FY2018' then amount2 else 0 end) as z20184  
from client_y
group by client_y.ttt  
order by client_y.ttt;
quit;
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群