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: RE: Creating a variable from overlapping intervals


From   "Keith Dear" <Keith.Dear@anu.edu.au>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Creating a variable from overlapping intervals
Date   Thu, 30 Dec 2010 16:15:24 +1100

Nanlesta,
Think about what is necessary for #2 NOT to be concurrent with #1:
either #2 must start after #1 finished, or v.v.:

gen byte newvariable = ! (first2>last1 | first1>last2)
or equivalently:
gen byte newvariable = first2<last1 & first1<last2

Perhaps you need <=, >= rather than <, >.
kd

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Nanlesta
Pilgrim
Sent: Thursday, 30 December 2010 3:14 PM
To: statalist@hsphsun2.harvard.edu
Subject: st:Creating a variable from overlapping intervals

Dear Statalist,

My apologies for this very simple coding question.  While I know what
to do conceptually, I appear to get lost in the coding.
I am trying to determine if the participants in my study have
concurrent sexual relationships.  For each partner of the participant,
I have the number of days(or months or years) ago they first and last
had sex with that partner.  I am attempting to write a code to create
one variable that would use all that information to tell me if the
partnership is concurrent.

Essentially:  If the first sex month (or first sex & last sex) of
partner 2 occurs within the first and last sex months of partner 1,
then newvariable=1

Thanks!
Nanlesta
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   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   |   Site index