Is This Content Helpful?
We're glad to know this article was helpful.
How can a numeric string, contained in a variable, be formatted to use commas to delimit digits in values greater that 999? For example, can the string 100000 be shown as 100,000?
This can be accomplished by parsing the necessary string length and inserting
commas. The following AML inserts commas every three digits:
&DO &WHILE %x% >= 1000
&SETVAR temp = [SUBSTR %x% [CALC [LENGTH %x%] - 2] [LENGTH %x%]]
&SETVAR new = ,%temp%%new%
&SETVAR x = [SUBSTR %x% 1 [CALC [LENGTH %x%] - 3]]
&IF [NULL %new%] &THEN &SETVAR new = %x%
&ELSE &SETVAR new = %x%%new%
&TYPE NEW IS %new%
&SETVAR .return = %new%