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 |