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-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

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