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: Data Management question


From   Hitesh Chandwani <[email protected]>
To   [email protected]
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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index