作者MOONY135 (谈无慾)
看板Statistics
标题Re: [程式] SAS资料处理问题
时间Thu May 7 20:19:46 2015
※ 引述《ooorrrzzz (orz)》之铭言:
: [软体程式类别]:
: SAS
: [程式问题]:
: 资料处理
: [软体熟悉度]:
: 中(3个月到1年)
: [问题叙述]:
: 请问我有资料格式如下
: date id score
: 201301 001 60
: 201302 001 80
: 201303 001 70
: 201301 002 50
: 201302 002 100
: 请问我要把每个id中,date的资料补到201412
: score的资料则是沿用曾出现过的最後一笔资料
: 仅用id 001举例
: ex: date id score
: 201301 001 60
: 201302 001 80
: 201303 001 70
: 201304 001 70
: 201305 001 70
: 201306 001 70
: ... ... ...
: 201412 001 70
懒人解法
proc sort data=test out=test; by id; run;
data A1;
set test;
by id;
if last.id then delete;
run;
data B1;
set test;
by id;
if last.id then OUTPUT;
run;
data B2;
set B1;
do i=1 to intck('month',date,'01dec2014'd);
date=intnx('month',date,1,'same');
output;
end;
drop i ;
run;
DATA FINAL;
SET A1 B1 B2;
RUN;
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 1.174.247.130
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Statistics/M.1431001188.A.ECD.html