由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Statistics版 - Another SAS question
相关主题
SAS help: how to count missing values of columns in a datasetsSas问题, 有包子
求一段SAS code请教版上高人一个SAS编程问题
SAS里怎么根据VALUE来选择需要OUTPUT的COLUMNSPlease help with a SAS macro
%do questionshelp for SAS code
请教一下SAS编程的一个问题SAS一问
遇到个SAS 问题,求教large dataset impot into SAS
SAS problem ask for help!工作中SAS问题 —另一个问题请教!
question about SAS BASE 123 No.64?how to read in 1/0 datasets in SAS?
相关话题的讨论汇总
话题: column话题: value话题: cum话题: want话题: record
进入Statistics版参与讨论
1 (共1页)
c****y
发帖数: 584
1
I have a dataset looks like this
x y z
a A 1
a A 2
a C 3
b C 1
b B 2
b B 3
b A 4
b D 5
c A 1
c C 2
d D 1
d A 2
e A 1
e D 2
....
I want it to look like this
x y z
a A 2
a C 3
b A 4
b D 5
c A 1
c C 2
e A 1
e D 2
....
Basically for each value in column x, I want the last record of A in column
y and the following record of each value in column x. If there is no non_A
value followed, delete all records of that value in column x.
Dont know if I make myself clearly enough but any help will be appreciated.
D******n
发帖数: 2836
2
data a1;
input x $ y $ z;
datalines;
a A 1
a A 2
a C 3
b C 1
b B 2
b B 3
b A 4
b D 5
c A 1
c C 2
d D 1
d A 2
e A 1
e D 2
;
run;
proc print;run;
data a2;
set a1;
by x;
if first.x then cum_A = 0;
cum_a + (y="A");
num = _n_;
run;
proc sql;
select * from a2
group by x
having cum_a>=max(cum_a) and sum(cum_a)>1
order by x,num;
quit;

【在 c****y 的大作中提到】
: I have a dataset looks like this
: x y z
: a A 1
: a A 2
: a C 3
: b C 1
: b B 2
: b B 3
: b A 4
: b D 5

c****y
发帖数: 584
3
Thanks very much for your code. but it didnt give me the result I want.
More help needed!!!
c****y
发帖数: 584
4
Thanks very much for your code. but it didnt give me the result I want.
More help needed!!!
c****y
发帖数: 584
5
Thanks very much for your code. but it didnt give me the result I want.
More help needed!!!
t******g
发帖数: 27
6
I think you should use the template and spend sometime google some key words
(e.g., first., last., by group) to find specific solution you are looking
for.
No one knows exactly what you want and no one here is paid to debug the code
for you.

【在 c****y 的大作中提到】
: Thanks very much for your code. but it didnt give me the result I want.
: More help needed!!!

1 (共1页)
进入Statistics版参与讨论
相关主题
how to read in 1/0 datasets in SAS?请教一下SAS编程的一个问题
SAS处理Large Dataset太慢了,怎么办?遇到个SAS 问题,求教
急!一个简单的SAS问题,请大家帮帮解释一下!多谢!SAS problem ask for help!
Please help me with SAS! Thank you!question about SAS BASE 123 No.64?
SAS help: how to count missing values of columns in a datasetsSas问题, 有包子
求一段SAS code请教版上高人一个SAS编程问题
SAS里怎么根据VALUE来选择需要OUTPUT的COLUMNSPlease help with a SAS macro
%do questionshelp for SAS code
相关话题的讨论汇总
话题: column话题: value话题: cum话题: want话题: record