BookmarkSubscribeRSS Feed
AnnaBrown
Community Manager

Hi Community,

 

A common question asked here is how to add leading zeros to a SAS value. SAS' Peter Styliadis, explains the process in this tutorial.

 

 

  

1 REPLY 1
LaurieF
Barite | Level 11

Want to add on something really stupid? This is from the days before %sysfunc, putn and the z format...

 

%let j = %substr(000&j, %length(&j), 4);

For values of j up to 9999, right-justify and zero-fill j. Want longer numbers? Add zeros, and change the last parameter.

 

I used this construct for years, but the documentation was usually fairly thorough.

 

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 1 reply
  • 657 views
  • 1 like
  • 2 in conversation