Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Measuring duration between age 13 and 19

    Hi people,
    Supposed i want to measure marriage timing among pregnant and non pregnant adolescents (age 13 to 19) using cmc variables, how do i go about creating my duration variable in this case. I have already created the event, which is experiencing 1st marriage. Below are some of the steps i followed:

    Event Variable (1st Marriage):
    tab v509 /*date of 1st cohabitation (cmc)*/
    tab v511 /*age at first cohabitation in years*/
    gen EVENT_1STMAR = .
    replace EVENT_1STMAR = 1 if v509 !=. & v511 >= 13 | v511 <=19
    replace EVENT_1STMAR = 0 if v509 ==. & v511 <=12 | v511 >=20
    tab EVENT_1STMAR, m

    Now Duration:
    tab v010 /*respondent's year of birth*/
    tab v508 /*respondent's year of first cohabitation*/
    tab v011 /*date of birth (cmc)*/
    tab v008 /*Date of interview (cmc)*/

    gen DURATION =.
    replace DURATION = (v508 - v010 )*12 + v011 - v509 if EVENT_1STMAR == 1
    replace DURATION = v008 if EVENT_1STMAR == 0

    Note: the duration should start at age 13 and end when the respondent turns 20 or month of interview or at 1st cohabitation. This is where my problem!

    Your comments and guidance will be highly appreciated.

    Thanks in advance.



  • #2
    Hello, and welcome to Statalist.

    My guess is that this line is the problem:
    Code:
    replace DURATION = (v508 - v010 )*12 + v011 - v509 if EVENT_1STMAR == 1
    The first part (v508 - v010 )*12 is in the unit of months, but v011 and v509 are usually the total number of days since Stata's internal reference date (Jan 1st 1960). So, it's natural that the answer does not make sense.

    Could you please check out the FAQ (http://www.statalist.org/forums/help) and find out how to use the command dataex to post some sample data? It's necessary for us to know the variable format before being able to help. Notice that they don't need to be the real data, just the real format. You may change up the information to mask the participant's privacy if necessary.

    Also, I'm not sure what is meant by "cmc", please spell that out. And it seems there is a mixture of mother's birthday and baby's birthday? It'd be great to specify that clearly as well if that is the case.

    Comment


    • #3
      Hi Ken, thanks for your welcome and assistance.
      Yes, this is where the problem is. I have define each of the variables in the above text. The first part: is the difference between respondent's year of 1st cohabitation (i.e. v508) and respondent's year of birth (i.e. v010) by 12. The second part is the difference between respondent's date of birth (i.e. v011) and respondent's date of first cohabitation (i.e. v509). Both v011 and v509 variables are in century month, this is what i mean by cmc.
      So this line: replace DURATION = (v508 - v010 )*12 + v011 - v509 if EVENT_1STMAR == 1 measures time/duration to first cohabitation from birth. However, i wanted to start the process time from age 13 and end at age 20. This is where i have a problem to do using variables in century month. Below is the example data [CODE] * Example generated by -dataex-. To install: ssc install dataex clear input int v509 byte v511 int(v011 v508 v010 v008) 1226 14 1052 2002 1987 1439 1226 14 1052 2002 1987 1439 1226 14 1052 2002 1987 1439 1226 14 1052 2002 1987 1439 1226 14 1052 2002 1987 1439 1326 15 1138 2010 1994 1439 1326 15 1138 2010 1994 1439 1326 15 1138 2010 1994 1439 1247 19 1013 2003 1984 1439 1249 17 1042 2004 1986 1439 1249 17 1042 2004 1986 1439 1249 17 1042 2004 1986 1439 1099 10 979 1991 1981 1439 1099 10 979 1991 1981 1439 1099 10 979 1991 1981 1439 1238 21 982 2003 1981 1439 1238 21 982 2003 1981 1439 1238 21 982 2003 1981 1439 1238 21 982 2003 1981 1439 1266 11 1124 2005 1993 1439 1266 11 1124 2005 1993 1439

      Comment


      • #4
        Oops! The data looks messy after posting. What am i missing?

        Comment


        • #5
          Trying again to see if it appears the same

          * Example generated by -dataex-. To install: ssc install dataex
          clear
          input int v509 byte v511 int(v011 v508 v010 v008)
          1226 14 1052 2002 1987 1439
          1226 14 1052 2002 1987 1439
          1226 14 1052 2002 1987 1439
          1226 14 1052 2002 1987 1439
          1226 14 1052 2002 1987 1439
          1326 15 1138 2010 1994 1439
          1326 15 1138 2010 1994 1439
          1326 15 1138 2010 1994 1439
          1247 19 1013 2003 1984 1439
          1249 17 1042 2004 1986 1439
          1249 17 1042 2004 1986 1439
          1249 17 1042 2004 1986 1439
          1099 10 979 1991 1981 1439
          1099 10 979 1991 1981 1439
          1099 10 979 1991 1981 1439
          1238 21 982 2003 1981 1439
          1238 21 982 2003 1981 1439
          1238 21 982 2003 1981 1439
          1238 21 982 2003 1981 1439
          1266 11 1124 2005 1993 1439

          Comment


          • #6
            Thank you, to paste that correctly, after you have used the dataex command, copy the first like that starts with CODE, to the last line that starts with /CODE on the output. Paste the whole thing here, and it should be formatted correctly. Could you do that again and make sure the end is also pasted? Your v509, v011, and v008 do not seem to be entered as raw data, some other format may be applied, and currently those formats are missing.

            Comment


            • #7
              Now here once again. I hope it works.

              Code:
              * Example generated by -dataex-. To install: ssc install    dataex
              clear
              input int v509 byte v511 int(v011 v508 v010 v008)
              1226 14 1052 2002 1987 1439
              1226 14 1052 2002 1987 1439
              1226 14 1052 2002 1987 1439
              1226 14 1052 2002 1987 1439
              1226 14 1052 2002 1987 1439
              1326 15 1138 2010 1994 1439
              1326 15 1138 2010 1994 1439
              1326 15 1138 2010 1994 1439
              1247 19 1013 2003 1984 1439
              1249 17 1042 2004 1986 1439
              1249 17 1042 2004 1986 1439
              1249 17 1042 2004 1986 1439
              1099 10  979 1991 1981 1439
              1099 10  979 1991 1981 1439
              1099 10  979 1991 1981 1439
              1238 21  982 2003 1981 1439
              1238 21  982 2003 1981 1439
              1238 21  982 2003 1981 1439
              1238 21  982 2003 1981 1439
              1266 11 1124 2005 1993 1439
              1266 11 1124 2005 1993 1439
              1266 11 1124 2005 1993 1439
              1266 11 1124 2005 1993 1439
              1266 11 1124 2005 1993 1439
              1266 11 1124 2005 1993 1439
              1269 17 1058 2005 1988 1439
              1269 17 1058 2005 1988 1439
              1269 17 1058 2005 1988 1439
              1269 17 1058 2005 1988 1439
              1355 28 1018 2012 1984 1439
              1355 28 1018 2012 1984 1439
              1343 21 1083 2011 1990 1439
              1343 21 1083 2011 1990 1439
              1404 44  866 2016 1972 1439
              1404 44  866 2016 1972 1439
              1404 44  866 2016 1972 1439
              1404 44  866 2016 1972 1439
              1404 44  866 2016 1972 1439
              1396 15 1208 2016 2000 1439
              1396 15 1208 2016 2000 1439
              1401 19 1169 2016 1997 1439
              1401 19 1169 2016 1997 1439
              1238 10 1116 2003 1992 1439
              1238 10 1116 2003 1992 1439
              1238 10 1116 2003 1992 1439
              1238 10 1116 2003 1992 1439
              1190 28  848 1999 1970 1439
              1190 28  848 1999 1970 1439
              1190 28  848 1999 1970 1439
              1242 16 1049 2003 1987 1439
              1242 16 1049 2003 1987 1439
              1247 23  960 2003 1979 1439
              1247 23  960 2003 1979 1439
              1265 25  960 2005 1979 1439
              1324 20 1078 2010 1989 1439
              1324 20 1078 2010 1989 1439
              1324 20 1078 2010 1989 1439
              1324 20 1078 2010 1989 1439
              1213 21  959 2001 1979 1439
              1213 21  959 2001 1979 1439
              1213 21  959 2001 1979 1439
              1213 21  959 2001 1979 1439
              1306 28  969 2008 1980 1439
              1306 28  969 2008 1980 1439
              1306 28  969 2008 1980 1439
              1223 26  901 2001 1975 1439
              1223 26  901 2001 1975 1439
              1416 25 1108 2017 1992 1439
              1344 15 1157 2011 1996 1439
              1344 15 1157 2011 1996 1439
              1344 15 1157 2011 1996 1439
              1095 15  915 1991 1976 1439
              1095 15  915 1991 1976 1439
              1095 15  915 1991 1976 1439
              1095 15  915 1991 1976 1439
              1095 15  915 1991 1976 1439
              1095 15  915 1991 1976 1439
              1102 14  925 1991 1977 1439
              1102 14  925 1991 1977 1439
              1102 14  925 1991 1977 1439
              1102 14  925 1991 1977 1439
              1102 14  925 1991 1977 1439
              1102 14  925 1991 1977 1439
              1117 13  952 1993 1979 1439
              1117 13  952 1993 1979 1439
              1117 13  952 1993 1979 1439
              1117 13  952 1993 1979 1439
              1117 13  952 1993 1979 1439
              1387 14 1216 2015 2001 1439
              1304 19 1074 2008 1989 1439
              1304 19 1074 2008 1989 1439
              1304 19 1074 2008 1989 1439
              1304 19 1074 2008 1989 1439
              1304 19 1074 2008 1989 1439
              1425 18 1202 2018 2000 1439
              1350 22 1085 2012 1990 1439
              1350 22 1085 2012 1990 1439
              1350 22 1085 2012 1990 1439
              1316 18 1093 2009 1991 1439
              1316 18 1093 2009 1991 1439
              end

              Comment

              Working...
              X