Bookmark and Share

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]

Re: st: display number of decimal places


From   Ronnie Babigumira <rb.glists@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: display number of decimal places
Date   Tue, 11 Sep 2012 09:39:08 +0200

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/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index