The reason is you are applying a character function - LENGTH - to a number - 12345. So SAS is automatically converting the number into a character variable using the BEST12. SAS format.
Inside SAS your number now looks like this (ignore the surrounding quotes) - ' 12345' - in other words it has 7 blank spaces in front of the number.
So that is why your look runs 12 times. If you changed a=12345 to a='12345' it would loop 5 times.
The SAS Users Group for Administrators (SUGA) is open to all SAS administrators and architects who install, update, manage or maintain a SAS deployment.