Looks like an attempt to fix the mistake of storing codes as a number, but this is bound to fail anyway, see this example:
data _null_; am = 9223460604630017; format am 19.; ambs = put(am,z19.); put am= / ambs=; run;
Run it, and read the log.
Z19. is a format specification. Just like DATE9. is a format specification.
Z is the name of the format. 19 is the width you want it to use to display the value.
You use the Z format to display integers with leading zeros. So whatever magnitude the value has it will always print with 19 digits adding zeros in the front if needed.
But remember that SAS stores all numbers as 64 bit binary floating point values. So the largest integer it can store before you start seeing gaps is smaller than 19 digits long.
9077 data _null_; 9078 exactint = constant('exactint'); 9079 put exactint Z19.; 9080 run; 0009007199254740992
So if you have any numbers that are larger than 9,007,199,254,740,992 then you cannot count on all of those digits being properly stored as a number.
That is one reason why it would have been better to have created the variable as character to begin with, to avoid loss of precision in the value.
What does z19. Means
i thought it mean to add 3 zero in front so becomes 19 digits, am I right.
Not necessarily if the variable is defined a CHARACTER as shown in your example. A numeric format cannot be used with a Character value and would result in an ERROR of the form "Format $Z not found". Unless somewhere you have a custom character format named Z in your current format search path. At which point I have no idea what the result might be as we would need the definition of that format.
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.