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.

# Re: st: display number of decimal places

 From Ronnie Babigumira To statalist@hsphsun2.harvard.edu Subject Re: st: display number of decimal places Date Tue, 11 Sep 2012 10:20:00 +0200

```I fully agree with you Nick.

My first thought was along the precision/-format- lines but on reading the email again, I saw that the Rebecca was interested in the maximum number of decimals so I assumed she had considered both but still wanted to go ahead and count hence my example with observations having different places.

--
010100100110111101101110011011100110100101100101

On Tuesday, September 11, 2012 at 9:56 AM, Nick Cox wrote:

> This is a much more tangled question than Ronnie's examples might seem
> to imply.
>
> If the problem really is keeping track of exactly how many decimal
> places were entered (meaning, input) there is only one infallible
> method: entering the data as a string and working out the number by
> string manipulation.
>
> Otherwise, as my earlier post in this thread indicated, the idea that
> there is a fixed number of decimal places which is a characteristic of
> non-integer data is just a confusion. Only when a decimal can be
> represented exactly by a binary is there an unequivocal answer.
>
> Nick
>
> On Tue, Sep 11, 2012 at 8:39 AM, Ronnie Babigumira <rb.glists@gmail.com (mailto:rb.glists@gmail.com)> wrote:
> > One way to do it (there may be more direct ways)
> >
> > clear
> > input x y
> > -1.273682 1.1234
> > 1.1 1.2345
> > 1.12 1.12
> > end
> >
> > gen ndmals_x = length(substr(string(x)),strpos(string(x),"."),.)-1
> > gen ndmals_y = length(substr(string(y)),strpos(string(y),"."),.)-1
> >
> > * To get max
> > egen max_ndmals_x = max(ndmals_x)
> > egen max_ndmals_y = max(ndmals_y)
> >
> >
> >
> >
> > list
> >
> > Ronnie
> > --
> > 010100100110111101101110011011100110100101100101
> >
> >
> >
> >
> > On Tuesday, September 11, 2012 at 9:21 AM, Rebecca Coates wrote:
> >
> > > Dear Statlist,
> > > Is there a way I can produce a list that shows not the number of columns in a variable, but the maximum number of decimal places after the decimal point?
> > > For example, the variable RPZ_S1 is a float variable, with the format %9.0g and contains Z scores.
> > > Example values look like this: -1.273682
> > > I would like to produce a list that tells me that variable RPZ_S1 contains 6 decimal places.
> > >
> > > Thank you
> > > Rebecca Coates
> > >
> > >
> > > Rebecca Coates
> > > Data Archivist/ PhD Candidate
> > > Australian Data Archive- UQ Node
> > > Institute for Social Science Research
> > > The University of Queensland
> > > Room 419, Level 4, GPN3 (Building 39A), Campbell Road
> > > ST LUCIA QLD 4072
> > > AUSTRALIA
> > >
> > > Phone: +61 7 334 60747
> > > Email: r.coates@uq.edu.au (mailto:r.coates@uq.edu.au)
> > > Website: http://www.issr.uq.edu.au | http://www.ada.anu.edu.au
> > > CRICOS Provider No. 00025B
> > >
> > > This email is intended solely for the addressee. It may contain private or confidential information. If you are not the intended addressee, you must take no action based on it, nor show a copy to anyone. Kindly notify the sender by reply email. Opinions and information in this email which do not relate to the official business of The University of Queensland shall be understood as neither given nor endorsed by the University.
> > >
> > > Please consider the environment before printing this e-mail.
> > >
> > >
> > >
> > >
> > > *
> > > * 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/
```