Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

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

From |
"Martin Weiss" <martin.weiss1@gmx.de> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
AW: AW: st: AW: float to numeric?? |

Date |
Mon, 21 Jun 2010 17:56:24 +0200 |

<> Ok, so Maarten defended my example while I was away from my home base. Thanks for that. Stata gives you a note after each -replace- operation, like "(2 real changes made)", which provides you with a hint whether your operation succeeded. After the first three -replace-, Stata will report "0" changes, while the last three, with the -float()- function present, will lead to the appropriate number of changes. HTH Martin -----Ursprüngliche Nachricht----- Von: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Özlen D. Luznar Gesendet: Montag, 21. Juni 2010 15:55 An: statalist@hsphsun2.harvard.edu Betreff: Re: AW: st: AW: float to numeric?? Hey Martin. Thanks so much for your time. I hate to take more of your time but I really do not understand what you mean below: where you use the inp command, can you explain what you mean there?? But note the difference that the -float()- function does make to the > result > here (we do not have your data, hence the example): > > ************* > clear* > inp chipeligrate povcat > 1.92 1 > 1.92 2 > 1.92 3 > 1.92 4 > 1.91 1 > 1.93 3 > end > gen eligstatus =. > replace eligstatus = 1 if chipeligrate ==1.92 & (povcat == 1 | povcat == > 2) > replace eligstatus = 2 if chipeligrate ==1.92 & (povcat == 3) > replace eligstatus = 3 if chipeligrate ==1.92 & (povcat == 4) > replace eligstatus = 1 if chipeligrate ==float(1.92) & (povcat == 1 | > povcat > == 2) > replace eligstatus = 2 if chipeligrate ==float(1.92) & (povcat == 3) > replace eligstatus = 3 if chipeligrate ==float(1.92) & (povcat == 4) > l > ************* > > <> > > " I also do not understand why float function as some recommended below > does > not work. Without the float. the calculation: > > replace eligstatus = 1 if chipeligrate ==1.92 & (povcat == 1 | povcat == > 2) > replace eligstatus = 2 if chipeligrate ==1.92 & (povcat == 3) > replace eligstatus = 3 if chipeligrate ==1.92 & (povcat == 4) > > will work for instance for values where povcat == 3 or povcat == 4 but > will NOT work for obs. where povcat == 1 | 2?? returning missing values > for those obs. for the eligstatus variable. I have no explanation for > that. If the value is stored as float, shouldn't the calculation NOT work > for all values??" > > > > > > > But note the difference that the -float()- function does make to the > result > here (we do not have your data, hence the example): > > ************* > clear* > inp chipeligrate povcat > 1.92 1 > 1.92 2 > 1.92 3 > 1.92 4 > 1.91 1 > 1.93 3 > end > gen eligstatus =. > replace eligstatus = 1 if chipeligrate ==1.92 & (povcat == 1 | povcat == > 2) > replace eligstatus = 2 if chipeligrate ==1.92 & (povcat == 3) > replace eligstatus = 3 if chipeligrate ==1.92 & (povcat == 4) > replace eligstatus = 1 if chipeligrate ==float(1.92) & (povcat == 1 | > povcat > == 2) > replace eligstatus = 2 if chipeligrate ==float(1.92) & (povcat == 3) > replace eligstatus = 3 if chipeligrate ==float(1.92) & (povcat == 4) > l > ************* > > > > HTH > Martin > > > -----Ursprüngliche Nachricht----- > Von: owner-statalist@hsphsun2.harvard.edu > [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Özlen D. > Luznar > Gesendet: Montag, 21. Juni 2010 15:06 > An: statalist@hsphsun2.harvard.edu > Betreff: Re: st: AW: float to numeric?? > > Hi Martin, > > I am really confused. I have been a stata user for some time but clearly > I am not as strong as many of you. > > Please do tell, why?? this chip elig rate simply is an eligibility rate > at the state level-- can be between 10% and 400% of the FPL hence-- .1 to > 4 varying values. I do not neet a complicated definition. or 9 decimals > etc. > > Please help me what I can do to make this variable more user friendly. > All I need is 2 decimals. As I think some states have eligibility of 185 > % or 17% etc. > > I also do not understand why float function as some recommended below does > not work. Without the float. the calculation: > > replace eligstatus = 1 if chipeligrate ==1.92 & (povcat == 1 | povcat == > 2) > replace eligstatus = 2 if chipeligrate ==1.92 & (povcat == 3) > replace eligstatus = 3 if chipeligrate ==1.92 & (povcat == 4) > > will work for instance for values where povcat == 3 or povcat == 4 but > will NOT work for obs. where povcat == 1 | 2?? returning missing values > for those obs. for the eligstatus variable. I have no explanation for > that. If the value is stored as float, shouldn't the calculation NOT work > for all values?? > > I am still confused. I aprpeciate all your help with this. > > Thank you. > >> >> <> >> >> >> BTW, Özlen, the major distinction in Stata is between "numeric" and >> "string" >> variables. Within "numeric", you have data types such as integer or >> float. >> The "range" returned by -codebook- for your "chipeligrate" variable >> indicates that one of its values, the minimum, is "0.1", which cannot be >> held as integer: >> >> *** >> clear* >> inp myvar >> 0.1 >> end >> d >> recast int myvar >> *** >> >> If you -force- it via - recast int myvar, force-, the former "0.1" will >> become "0". Probably not what you want... >> >> >> HTH >> Martin >> >> >> -----Ursprüngliche Nachricht----- >> Von: owner-statalist@hsphsun2.harvard.edu >> [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Özlen D. >> Luznar >> Gesendet: Montag, 21. Juni 2010 04:43 >> An: statalist@hsphsun2.harvard.edu >> Betreff: st: float to numeric?? >> >> Hi everyone, >> >> >> I have a variable stored as float chip eligibility rate variable. very >> straightforward - varies between .1 and 4. But it is stored as float >> and >> gives me major toruble when I am using the values to generate new >> variables etc. I would like to store it as numeric so that stata can >> recognize the values of this variable. Does anyone have experience with >> this?? >> . codebook chipeligrate >> >> > ---------------------------------------------------------------------------- >> -- >> chipeligrate chip eligibility rate by year and age and >> state >> > ---------------------------------------------------------------------------- >> -- >> >> type: numeric (float) >> >> range: [.1,4] units: .01 >> unique values: 40 missing .: 0/6585 >> >> mean: 1.92923 >> std. dev: .720279 >> >> percentiles: 10% 25% 50% 75% >> 90% >> 1 1.5 2 2 >> 3 >> >> I need to chnage this variable and store is as int but I can not figure >> out how. So far I tried compress but it seemed to work but when I >> described the variable, still float. >> >> Thanks so much for your help in advance. >> >> -- >> Özlen D. Luznar >> PhD Candidate - Public Policy >> Graduate Research Assistant >> University of Maryland Baltimore County (UMBC) >> 1000 Hilltop Circle >> Baltimore, MD 21250 >> 410-455-6527 office >> 443-846-5010 cell >> >> * >> * 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/ >> >> > > > -- > Özlen D. Luznar > PhD Candidate - Public Policy > Graduate Research Assistant > University of Maryland Baltimore County (UMBC) > 1000 Hilltop Circle > Baltimore, MD 21250 > 410-455-6527 office > 443-846-5010 cell > > * > * 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/ > > -- Özlen D. Luznar PhD Candidate - Public Policy Graduate Research Assistant University of Maryland Baltimore County (UMBC) 1000 Hilltop Circle Baltimore, MD 21250 410-455-6527 office 443-846-5010 cell * * 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/

**References**:**st: float to numeric??***From:*"Özlen D. Luznar" <ozlend1@umbc.edu>

**st: AW: float to numeric??***From:*"Martin Weiss" <martin.weiss1@gmx.de>

**Re: st: AW: float to numeric??***From:*"Özlen D. Luznar" <ozlend1@umbc.edu>

**AW: st: AW: float to numeric??***From:*"Martin Weiss" <martin.weiss1@gmx.de>

**Re: AW: st: AW: float to numeric??***From:*"Özlen D. Luznar" <ozlend1@umbc.edu>

- Prev by Date:
**RE: st: Comparison of the R-squared in a loglog and linear model** - Next by Date:
**Re: st: Svy poststratification VS Pweighting** - Previous by thread:
**Re: AW: st: AW: float to numeric??** - Next by thread:
**re: st: float to numeric??** - Index(es):