Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: identifying rounded numbers


From   "Anja Decressin" <[email protected]>
To   "Statalist@Hsphsun2. Harvard. Edu" <[email protected]>
Subject   st: identifying rounded numbers
Date   Fri, 7 Jun 2002 13:43:59 -0400

Dear Statalist,
I have wage data and would like to identify if an observation has been
rounded.
I would like to know if a number has been rounded with regard to the last
digit and the last two digit.

obervation number		wage	"last digit rounded"	"last two digit rounded"
1. 				500	yes				yes
2.				1441	no				no
3.				1450	yes				no

Is there a way to identify if a number is an integer? Then I could just
divide it by 10 or 100 and check if it is an integer.

I could alsp try to make a string variable out of the "wage"-value
(using -decode(wage),gen(strwage)- would require me to create labels for the
values, probably through some loop), counting the length of the string
(through -length(s)-), and then using -index(strwage,"0")- and the length(s)
value to find the 0s.
This seems way too complicated.

I guess, I could program a loop
   	gen round10=.
	program define rounded10
	  local i=1
	  while`1' <=1000 {
		replace round10=1 if wage=i
		local i=`i' +1
		}
	end

but there must be Stata command for this?!

Anja Decressin (Ph.D.)
Georgetown University
http://www.georgetown.edu/users/decressa/
[email protected]

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   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