> to a standard five-digit number with leading zeros:
> 2 --> 00002
> 33 --> 00033
> 473 --> 00473
> 59724 --> 59724
Display with leading zeros is a matter of format:
di %05.0f 2
A more fundamental change is:
gen str5 newvar = string(oldvar,"%05.0f")