Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: float function question


From   David Airey <[email protected]>
To   Statalist <[email protected]>
Subject   st: float function question
Date   Tue, 16 Jun 2009 21:55:58 -0500

.

Why does the float function not work like this? I feel silly.

clear
input float x
0.00
0.01
0.03
0.10
0.30
1.00
end
generate str4 x_str = ""
replace x_str = "0.00" if float(x) == 0.0
replace x_str = "0.01" if float(x) == 0.01
replace x_str = "0.03" if float(x) == 0.03
replace x_str = "0.10" if float(x) == 0.1
replace x_str = "0.30" if float(x) == 0.3
replace x_str = "1.00" if float(x) == 1.0
list, clean

which gave

. list, clean

         x   x_str
  1.     0    0.00
  2.   .01
  3.   .03
  4.    .1
  5.    .3
  6.     1    1.00


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index