标题: how to add '0's in the tail [打印本页] 作者: shiyiming 时间: 2013-6-28 22:18 标题: how to add '0's in the tail data a;
input cpt $5.;
cards;
0059
69
035
04119
;
run;
I am trying to add '0'(s) in the tail of each value in data a(see above), if the value less than 5 digits. and the following data b is what I wanted:
data b:
00590
69000
03500
04119
Thanks!!!作者: shiyiming 时间: 2013-6-29 10:18 标题: Re: how to add '0's in the tail [code:fv4klgon]data b;
set a;
new_cpt=cats(cpt,"0000");
new_cpt=substr(compress(new_cpt),1,5);
run;
[/code:fv4klgon]作者: shiyiming 时间: 2013-7-1 10:30 标题: Re: how to add '0's in the tail [code:8zxen6i8]data a;
input cpt $5.;
cpt=prxchange('s/\s/0/',-1,cpt);
cards;
0059
69
035
04119
;[/code:8zxen6i8]