/***************************************************************************************************************** SAS file name: leading_zero.sas File location: __________________________________________________________________________________________________________________ Purpose: To demonstrate how to add leading zeros to numeric variables in SAS Author: Peter Clemmensen Creation Date: 03/11/2020 This program supports the blog post "Add Leading Zeros to Numeric Variable in SAS" on SASnrd.com *****************************************************************************************************************/ /* Example data */ data have; input x; datalines; 1 12 123 1234 12345 123456 1234567 12345678 123456789 ; /* Add leading zeros with the z. format */ data want; set have; format x z10.; run; proc print data = have; format x z10.; run; /* Use the z. format to create character varaible */ data want; set have; y = put(x, z10.); run;