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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 597 views
  • 1 like
  • 3 in conversation