If I set a format "%04.2f" I get the requested 2 decimal places for non-integer values, but integer values are displayed with no decimal point or decimal part - taking 1 character space instead of 4. (All the values are <10). This interferes with vertical alignment, so I would like to display zero as "0.00" rather than just "0". I thought of replacing zero with .00001 thinking it would round on output to "0.00", but that just causes Stata to switch to scientific format which uses even more character positions. Do I need to use -tostring- and -replace- the "0"'s with "0.00" or is there an easier way?
Code:
. . set obs 1 . gen x=0 . format x %04.2f . di x 0 the string . replace x=1.22 . di x 1.22

Comment