Reputation: 141
I'm using the CAT-Function to generate variable names:
variable=CAT(ID,ID2,Number)
The variable "number" is a number from the set {1,5,52,142,299}. As I want to have the same structure for all generated variables, I would like to add zeroes in front of the numbers, i.e. as {001,005,052,142,299}. How can I achieve that inside the CAT-function?
Best
Upvotes: 0
Views: 751
Reputation: 7602
The z
format adds leading zeros to a specified number of digits, in your case it would be z3.
. Use the put
function to convert it to a character string in the required format (cat
returns a character string by default, so would have to convert the number anyhow). You may want to consider cats
as an alternative, which will strip any leading or trailing blanks.
variable=CAT(ID,ID2,put(Number,z3.))
Upvotes: 2