How to add leading zeros to numeric variables
Have you ever asked to create a variable with leading zeros? I mean 1 to 001 and 2 to 002. If you were, do you know how.... SAS has a special numeric format Zw.d . which can include leading zeros. Zw.d Format in which, w : Width of variable. d : Decimal Point. Zw.d format writes standard numeric data with leading 0's. The Z w . d format is similar to the w.d format except that Z w . d pads right-aligned output with 0s instead of blanks. (Ref: SAS 9.2 Language Reference : Dictionary, 4th edition); Let me give you a scenario where this can be very useful: You have a variable called site with the numbers as 101, 999, 1001 and 1200. If you want to create a USUBJID variable with fixed length for all the subjects, we need to modify the site variable variables to fixed length. (length=4). You can do that using Z4.d format. Note: As this is a numeric format, this can be applied to numeric variables only. *z4.format is used to a...