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 at the end of May, and its replacement, statalist.org is already up and running.


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

st: Data Management question


From   Hitesh Chandwani <hchandwani.stata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: Data Management question
Date   Tue, 25 Jun 2013 11:46:15 -0500

Dear all,

I have a data management issue. I need to generate a couple of
indicator variables from variables that already exist in the dataset.

Let's call the required indicator vars X, Y, and Z with values of 1 or
0. Whether the value of these vars is 1 or 0 depends on the value of 5
other indicator variables (A, B, C, D, E). A-E are chronologically
ordered (i.e., A indicates an event that happened before B, which
happened before C, and so on).

For each observation:
X = 1 if at least 3 "consecutive" vars from A-E are equal to 1.
Y = 1 if at least 2 "consecutive" vars from A-E are equal to 1.
Z = 1 if only 1 or 2 "non-consecutive" vars from A-E are equal to 1.

I could do this the long way with repeated gen and replace commands
but I'm sure there's a better way to do it (only I don't know how).

Any input is much appreciated.

Thanks,
-- 
Hitesh S. Chandwani, MBBS, MS
University of Texas at Austin
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index