SAS中文论坛

 找回密码
 立即注册

扫一扫,访问微社区

查看: 1588|回复: 2
打印 上一主题 下一主题

how to add '0's in the tail

[复制链接]

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
楼主
 楼主| 发表于 2013-6-28 22:18:09 | 只看该作者

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!!!
回复 支持 反对

使用道具 举报

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
沙发
 楼主| 发表于 2013-6-29 10:18:21 | 只看该作者

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]
回复 支持 反对

使用道具 举报

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
板凳
 楼主| 发表于 2013-7-1 10:30:53 | 只看该作者

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]
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|手机版|Archiver|SAS中文论坛  

GMT+8, 2025-6-9 00:03 , Processed in 0.068415 second(s), 21 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表