由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Statistics版 - sas help
相关主题
请教flag问题请教高人如何用一个表格的列去替换另一个表格的列?
sas date variable exchange请教这种freq 该用什么code算(sas)?Thanks!
工作中SAS问题 —另一个问题请教!包子求sas 问题解决办法
sas新手请教一个问题SAS help Need! how to read this raw data
新手问个简单的sas问题请教一sas programmm
Sas问题, 有包子hi, an interview question
请教版上高人一个SAS编程问题overall mean in sas for several variables
请教sas code问题SAS help
相关话题的讨论汇总
话题: h1话题: question话题: missing话题: xxx话题: input
进入Statistics版参与讨论
1 (共1页)
x*z
发帖数: 67
1
data xxx;
input one;
dataline;
8
.
.
6
.
4
.
.
.
7
.
.
.
;
Question:
How can I make the missing . to the last non-missing?
like
8
8
8
6
6
4
4
4
4
7
7
7
7
Thank you!
s*******9
发帖数: 35
2
data test;
set xxx;
if one^=. then
do;
retain new_one;
new_one=one;
end;
run;
g*******y
发帖数: 380
3
try this:
data xxx (drop=two);
retain two;
input one;
if one ne . then two=one;
else one=two;output;
cards;
8
.
.
6
.
4
.
.
.
7
.
.
.
;
run;
x*z
发帖数: 67
4
非常感谢楼上两位!
你们的程序都很好用,祝你们好人有好福!
我也不知道包子是啥,否则一定给你们发包子。
x*z
发帖数: 67
5
Another similar question;
data xxx;
input one $;
dataline;
H1
.
.
H1
.
H1
.
.
H1
.
.
.
;
Question:
How can I identify each 'H1'?
For example, create another variable
like
H1 a
. a
. a
H1 b
. b
H1 c
. c
. c
H1 d
. d
. d
. d
;
Thank you!
g*******t
发帖数: 124
6
根据前面那个程序改的。
data new (drop= new_one);
input one $;
if _n_=1 then new_one=96;
if one ne "" then new_one+1;
seg=byte(new_one);
cards;
H1
.
.
H1
.
H1
.
.
H1
.
.
.
run;

【在 x*z 的大作中提到】
: Another similar question;
: data xxx;
: input one $;
: dataline;
: H1
: .
: .
: H1
: .
: H1

x*z
发帖数: 67
7
I will try it, gutenacht. But I don't quite understand it at this moment.
One more question, please help. Thank you!
data xxx;
input one;
dataline;
.
.
.
8
.
.
6
.
4
.
.
.
7
.
.
.
8
;
Question:
How can I make the missing . to the 'next' non-missing?
like
8
8
8
8
6
6
6
4
4
7
7
7
7
8
8
8
8
Thank you!
x*z
发帖数: 67
8
Thank you, gutenacht.
the program works greatttt! My question is where did you get the number 96?
By the way, since I have more than thousands of 'H1', is it possible to use
up all charactors? Any better idea?
The charator's format not important as long as i can identify each.
Can anyone help? Thanks.
g*******y
发帖数: 380
9
It's very good that I can always learn something from replies.
I think Byte function give you the character which is corresponding to the
number. For you question, I guess byte(96)=a.
And for you further question, I think byte function may only give you up to
255 characters. I don't know whether you can use character function to
combine the results of byte function, or if you don't mind, you can simply
use numeric value (My understanding is you are trying to identify each group
, right?)

?
use

【在 x*z 的大作中提到】
: Thank you, gutenacht.
: the program works greatttt! My question is where did you get the number 96?
: By the way, since I have more than thousands of 'H1', is it possible to use
: up all charactors? Any better idea?
: The charator's format not important as long as i can identify each.
: Can anyone help? Thanks.

x*z
发帖数: 67
10
Yes, byte(96)=a
For my data I would like it like x1......x2............x3..........X99999
any idea?
maybe create a variable like 'x'||num? I will try.
Thanks
g*******y
发帖数: 380
11
sorry, should be byte(97)=a.

【在 x*z 的大作中提到】
: Yes, byte(96)=a
: For my data I would like it like x1......x2............x3..........X99999
: any idea?
: maybe create a variable like 'x'||num? I will try.
: Thanks

g*******y
发帖数: 380
12
try this, it works, but I think the code is bad. I don't know how to use
views in proc sql, so I used two sql procedures. :(
data xxx(drop=new_one);
retain two;
input one;
if _n_=1 then new_one=97;
seg=byte(new_one);
if one ne . then do;
new_one+1;
end;
cards;
.
.
.
8
.
.
6
.
4
.
.
.
7
.
.
.
8
;
run;
proc sql;
create talbe oo as
select one as two, seg
from xxx
where one is not missing;
quit;
proc sql;
create table pp as
SELECT a.seg, b.two
FROM xxx AS A ,oo AS B
where a.seg=b.seg;
QUIT;

【在 x*z 的大作中提到】
: I will try it, gutenacht. But I don't quite understand it at this moment.
: One more question, please help. Thank you!
: data xxx;
: input one;
: dataline;
: .
: .
: .
: 8
: .

x*z
发帖数: 67
13
Thank you, geography !
Works great!
The only thing is still the potential problem to use up all charactors. :(
From my experience, views is the same as tables but run faster because it
just save query but not real table.
x*z
发帖数: 67
14
I revised as
data xxx(drop=new_one);
retain two;
input one;
if _n_=1 then new_one=0;
seg=compress('z'||left(put(new_one, z4.)))
if one ne . then do;
new_one+1;
end;
...
The running out of charactor problem solved.
Any better idea about this? Thanks
1 (共1页)
进入Statistics版参与讨论
相关主题
SAS help新手问个简单的sas问题
请教个SAS问题Sas问题, 有包子
请问sas中一个变量的内容被两个左斜杠(/)分成了三部分请教版上高人一个SAS编程问题
[提问]怎样sort这个dataset?请教sas code问题
请教flag问题请教高人如何用一个表格的列去替换另一个表格的列?
sas date variable exchange请教这种freq 该用什么code算(sas)?Thanks!
工作中SAS问题 —另一个问题请教!包子求sas 问题解决办法
sas新手请教一个问题SAS help Need! how to read this raw data
相关话题的讨论汇总
话题: h1话题: question话题: missing话题: xxx话题: input