x****i 发帖数: 400 | 1 我现在有个variable是character,如,
00121
0121
0122
122
AAAA
BBb
现在要把其中的数字leading zeros去掉,不管几个0都要去掉。我看了一下,如果光是
数字还是能弄的,可现在是这种混合形的,如果不能把其中的数字单独抽出来clean,怎
么做呢? | a********s 发帖数: 188 | 2 在网上看到一个类似的。
data a;
input a$;
datalines;
00121
0121
0122
122
AAAA
BBb
;
run;
data b(drop = x);
set a;
do until (x ne "0");
x=first(a);
if x="0" then substr(a,1,1)=" ";
a = left(a);
end;
run;
run; | x****i 发帖数: 400 | 3 It is working. What I find is use input function, but that only works for
numerical variable.
Thank you. | y****n 发帖数: 46 | 4 DATA XX;
INPUT XX $1-10;
IF NOT ANYALPHA(XX) THEN XX=LEFT(PUT(INPUT(XX,BEST.),10.));
CARDS;
00121
0121
0122
122
AAAA
BBb
;
RUN; | x****i 发帖数: 400 | 5 I forgot anyalpha, yours is simple.
Second floor's suggestion can be extensive and apply to other situations.
【在 y****n 的大作中提到】![](/moin_static193/solenoid/img/up.png) : DATA XX; : INPUT XX $1-10; : IF NOT ANYALPHA(XX) THEN XX=LEFT(PUT(INPUT(XX,BEST.),10.)); : CARDS; : 00121 : 0121 : 0122 : 122 : AAAA : BBb
|
|