SAS Enterprise Guide

Desktop productivity for business analysts and programmers
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...

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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
  • 2072 views
  • 0 likes
  • 3 in conversation