BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
woo
Barite | Level 11 woo
Barite | Level 11

Hello Friends please help me on this issue....

I have one numeric variable "a" as describe below (tot obs is like 100k). i want to add "0" (zeros) to make this num variable length 10. How can i do that?

have dataset

a

-----------

987654

892345

6787

9867543

87651234

want dataset should looks like this....

a

-----------

0000987654

0000892345

0000006787

0009867543

0087651234

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

using a put statement and the Z10 format. This will make a character variable though, as numbers can't have leading zeros.

new_num=put(num, z10.);

View solution in original post

3 REPLIES 3
slchen
Lapis Lazuli | Level 10

data have;
input x;
_x=put(input(strip(x),10.),z10.);
cards;
987654
892345
6787
9867543
87651234
;
run;

Reeza
Super User

using a put statement and the Z10 format. This will make a character variable though, as numbers can't have leading zeros.

new_num=put(num, z10.);

woo
Barite | Level 11 woo
Barite | Level 11

thanks a lot Reeza for your quick response.

I checked and it worked...

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 2242 views
  • 0 likes
  • 3 in conversation