Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | "Andreas Drichoutis" <adrihout@cc.uoi.gr> |
To | <statalist@hsphsun2.harvard.edu> |
Subject | RE: st: variable format |
Date | Thu, 10 Mar 2011 21:44:18 +0200 |
Well it didn't. I tried gen varnew=round(var,.01) and all it did is to create a copy of the original variable. Values are displayed with 2 decimals but the actual value is 7 decimals long. Andreas -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Sarah Edgington Sent: Thursday, March 10, 2011 9:28 PM To: statalist@hsphsun2.harvard.edu Subject: RE: st: variable format . What do you mean when you say the round function doesn't work? It really seems like that should be your best bet. -Sarah -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Andreas Drichoutis Sent: Thursday, March 10, 2011 11:25 AM To: statalist@hsphsun2.harvard.edu Subject: RE: st: variable format My concern is the actual value and neither the round function works nor changing the format to %3.2f . Any other ideas? Andreas -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Joerg Luedicke Sent: Thursday, March 10, 2011 9:20 PM To: statalist@hsphsun2.harvard.edu Subject: Re: st: variable format On Thu, Mar 10, 2011 at 1:53 PM, Joerg Luedicke <joerg.luedicke@gmail.com> wrote: > On Thu, Mar 10, 2011 at 1:27 PM, Andreas Drichoutis > <adrihout@cc.uoi.gr> wrote: >> Dear all, >> >> Some variables in my dataset are stored as float %8.0g . I need to >> have exactly 2 decimals for these variables, however Stata formats >> these with more decimals e.g., it stores the value of 8.77 as 8.7700005. >> >> How do I convert variables to 2 decimals only. > > http://lmgtfy.com/?q=stata+variable+format > > in your case it could be something like > > format %3.2f yourvariable > > if you numbers have no more than 3 digits > > J. > ...might need to add that if your concern is not the format but the actual value, you can round them using the round function together with generate or replace (-help round-). So if you wanted to replace your data you could do (if x is your variable): replace x =round(x, .01) J. * * 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/ * * 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/