BookmarkSubscribeRSS Feed
Smitha9
Fluorite | Level 6

Hi,

I have a character variables and I want to make it to 5digits by filling with zero at the starting.

ID

11

21

31

451

5671

 

Want:

00011

00021

00031

00451

05671

thank you in advance

2 REPLIES 2
Astounding
PROC Star

This should do it:

data want;
   set have;
   id = put(input(id, 5.), z5.);
run;
ballardw
Super User

What is the current defined Length of the variable? If it is not at least 5 then you will not have enough character spaces to place 5 characters in it.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 372 views
  • 1 like
  • 3 in conversation