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

Re: st: data manipulation


From   David K Evans <dkevans@fas.harvard.edu>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: data manipulation
Date   Tue, 9 Nov 2004 09:18:57 -0500 (EST)

One way would be to use the int function:

gen z=int(x)

'an expression' if x==z
'another expression' if x~=z

If x is an integer, than x will be equal to z. If not, they won't be
equal.
Dave

------------------------------------------------------------------------

PhD student, Harvard Economics Department
Phone: (O) 617-495-5634, (H) 617 - 493 - 1536
Address: Currier Mail Center #554, Cambridge, MA 02138

------------------------------------------------------------------------

On Tue, 9 Nov 2004, Nahid Tabatabai wrote:

> Hi,
> I have a simple question. I have a column (x) with integer and non-integer values, such as 2, 2.03. 1, 1.8, .... I want to use this column to identify each record by referring to the integer and alternatively non-integer values. How do I refer to them?
>
> for example:
>
> 'an expression'  if x==integer values
> 'another expression'  if x ~=integer values
>
> In these two examples how do I identify the integer and non-integer values?
>
> thanks,
> Nahid
>
>
> *
> *   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/
>
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index