Statalist


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

st: AW: float function question


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: AW: float function question
Date   Wed, 17 Jun 2009 09:00:57 +0200

<> 


Also note the FAQ on this point:
http://www.stata.com/support/faqs/data/float.html
http://www.stata.com/support/faqs/data/prec.html




HTH
Martin

-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von David Airey
Gesendet: Mittwoch, 17. Juni 2009 04:56
An: Statalist
Betreff: st: float function question

.

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/


*
*   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