I have string variables:
Please how do I format the first three observations to have zero before the decimal point?
Thanks
Code:
.2568 .0356 .025 0.256 0.5682
Thanks
clear input str6 whatever .2568 .0356 .025 0.256 0.5682 end replace whatever = "0" + whatever if substr(whatever, 1, 1) == "." list +----------+ | whatever | |----------| 1. | 0.2568 | 2. | 0.0356 | 3. | 0.025 | 4. | 0.256 | 5. | 0.5682 | +----------+
replace myvar="0"+myvar if regexm(myvar,"^\.")
destring myvar, replace format myvar %5.3f
Comment