标题: 求助数据的处理 [打印本页] 作者: shiyiming 时间: 2009-11-11 20:20 标题: 求助数据的处理 我现在的数据集是
name time value
x 20000308 1
x 20000603 2
x 20011028 3
x 20060104 3
y 20040308 3
y 20040604 7
y 20041206 3
y 20060104 67
我想得到的结果是
我现在的数据集是
name time value
x 20000308 1
......................
x 20000603 2
.........................
x 20011028 3
..........................
x 20060104 3
y 20040308 3
..........
y 20040604 7
......................
y 20041206 3
...............
y 20060104 67
........... 表示在原有的观测值中间插入时间序列,按照天排列,在原来两个观测值之间的NAME 还是X,VALUE取第二个观测值的VALUE,请问如何实现?作者: shiyiming 时间: 2009-11-11 23:15 标题: Re: 求助数据的处理 [code:2wba5j4d]data raw;
retain string;
infile 'd:\raw.txt' end=eof;
input;
if _n_=1 then string=_infile_;
if scan(string,1)=scan(_infile_,1) then
do;
do time=input(scan(string,2),yymmdd8.) to input(scan(_infile_,2),yymmdd8.)-1;
output;
end;
end;
else
do;
time=input(scan(string,2),yymmdd8.);
output;
end;
string=_infile_;
if eof then output;
format time yymmdd10.;
run;
data final(drop=string);
retain name time value;
length name $8;
set raw;
name=scan(string,1);
value=input(scan(string,3),best8.);
run;[/code:2wba5j4d]作者: shiyiming 时间: 2009-11-12 11:10 标题: Re: 求助数据的处理 NOTE: Infile 'd:\raw.txt' 是:
文件名=d:\raw.txt,
RECFM=V,LRECL=256
NOTE: 函数 INPUT 的参数(行 276 列 52)无效。
NOTE: 函数 INPUT 的参数(行 276 列 18)无效。
ERROR: 无效的 DO 循环控制信息,INITIAL 或 TO 表达式缺失,或 BY 表达式缺失、为 0 或无效。
RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
1 name time value 16
string=name time value eof=0 time=. _ERROR_=1 _INFILE_=name time value _N_=1
NOTE: 从 Infile 'd:\raw.txt' 中读取了 1 条记录。