全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
1222 2
2016-02-18
data score;                                                                                                                             
input id type $ score;                                                                                                                  
cards;                                                                                                                                 
1 math 87                                                                                                                              
1 chinese 79                                                                                                                           
2 math 98                                                                                                                              
3 math 90                                                                                                                              
2 chinese 85                                                                                                                           
;                                                                                                                                       
proc sort data=score;                                                                                                                  
by id; run;                                                                                                                             
data total;                                                                                                                             
set score;                                                                                                                              
by id;                                                                                                                                 
if first.id then total=0;                                                                                                               
total+score;                                                                                                                           
drop type pay;                                                                                                                          
if last.id then output;                                                                                                                 
proc print;                                                                                                                             
run;   
大神能不能解释一下data total;                                                                                                                             
set score;                                                                                                                              
by id;                                                                                                                                 
if first.id then total=0;                                                                                                               
total+score;                                                                                                                           
drop type pay;                                                                                                                          
if last.id then output;                                                                                                                 
proc print;                                                                                                                             
run;  各步的意思,最后得到的结果是: 程序结果

二维码

扫码加我 拉你入群

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

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

全部回复
2016-2-19 09:38:19
整体功能:按id汇总成绩
data total;                                                                                                            
set score;                                                                                                                              
by id;          *以上,略;                                                                                                                       
if first.id then total=0;  *某id 第一次出现,Total=0;                                                                                                            
total+score;   *total=total+Score;                                                                                                                        
drop type pay;                                                                                                                          
if last.id then output;  *某id最后一次出现,输出,即输出汇总的结果;                                                                                                               
proc print;                                                                                                                             
run;  
二维码

扫码加我 拉你入群

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

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

2016-2-19 11:18:20
co_fund 发表于 2016-2-19 09:38
整体功能:按id汇总成绩
data total;                                                                  ...
明白了,多谢
二维码

扫码加我 拉你入群

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

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

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

说点什么

分享

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