楼主: skanty
545 1

sas动态转置问题请教 [推广有奖]

  • 0关注
  • 0粉丝

初中生

14%

还不是VIP/贵宾

-

威望
0
论坛币
9 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
43 点
帖子
2
精华
0
在线时间
23 小时
注册时间
2013-5-31
最后登录
2025-7-11

楼主
skanty 发表于 2018-1-15 16:20:47 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币

现在有如下数据截图
原始数据


希望得到
效果图

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





二维码

扫码加我 拉你入群

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

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

关键词:EXCEL Pivot Table ABLE xcel SAS 动态转置

沙发
skanty 发表于 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;

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
扫码
拉您进交流群
GMT+8, 2026-1-18 16:41