Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: rounding values in a large subset of variables


From   Emeline Gauthiez <emeline.gauthiez@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: rounding values in a large subset of variables
Date   Tue, 11 Feb 2014 15:43:25 +0100

Dear members of statalist,

I am a very new user of stata, facing a few problems.

I have a large subset of variables all starting with the prefix eg_rs*,
with values between
0 and 2 I would like to round them all to 0, 1 or 2. (see example (actual
dataset is much larger))

I tried with the replace function :
replace eg_rs*=round(eg_rs*)

but it doesn't work...

-example begin-

What I have :
id    eg_rs2660    eg_rs3452    eg_rs7894
1001  1            0.99         0.85
1002  0            1            2
1003  2            1.99         1
1004  1.12         2            2
1005  0.3          0            1
1006  1            0            0.78


What I'd like :
id    eg_rs2660    eg_rs3452    eg_rs7894
1001  1            1            1
1002  0            1            2
1003  2            2            1
1004  1            2            2
1005  0            0            1
1006  1            0            1

-example end-

Any help will be very much appreciated, thanks!

Emeline
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index