SAS中文论坛
标题:
数据集插入空行
[打印本页]
作者:
shiyiming
时间:
2010-11-3 10:15
标题:
数据集插入空行
现在有数据集X,如下
a b c
4 4 1
2 3 1
3 6 2
4 5 2
5 5 3
4 7 3
现在要当c变量的值变化时,在两条数据中插入一空行,即
a b c
4 4 1
2 3 1
3 6 2
4 5 2
5 5 3
4 7 7
请问应该如何编程?谢谢
作者:
shiyiming
时间:
2010-11-3 10:30
标题:
Re: 数据集插入空行
[code:11scbhzp]data raw;
input a b c;
datalines;
4 4 1
2 3 1
3 6 2
4 5 2
5 5 3
4 7 3
;
data out;
do _n_=1 by 1 until(last.c);
set raw end=last;
by c notsorted;
output;
end;
call missing(of _all_);
if not last then output;
run;[/code:11scbhzp]
作者:
shiyiming
时间:
2010-11-22 12:51
标题:
Re: 数据集插入空行
hopewell编得太牛了,跟一个。
[code:3j4sjiuv]data raw;
input a b c; output;
if lag(c) ne lag2(c) then do;
a=. ; b=.; c=.; output;
end;
datalines;
4 4 1
2 3 1
3 6 2
4 5 2
5 5 3
4 7 3
4 8 3
;
run;[/code:3j4sjiuv]
作者:
shiyiming
时间:
2010-11-22 13:55
标题:
学习notsorted用法
[code:1n4un784]data raw;
input a b c;
datalines;
4 4 1
2 3 1
2 1 1
3 6 2
4 5 2
5 5 3
4 7 3
;
data ex;
set raw;
by c notsorted;
output;
if last.c then
do;
call missing(of _all_);
output;
end;
run;
[/code:1n4un784]
作者:
shiyiming
时间:
2010-11-23 23:34
标题:
Re: 数据集插入空行
非主流
作者:
shiyiming
时间:
2010-11-24 23:08
标题:
Re: 数据集插入空行
猪头兄高才,佩服佩服
欢迎光临 SAS中文论坛 (https://mysas.net/forum/)
Powered by Discuz! X3.2