Announcement

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

  • Reshape only for certain responses

    Hi all, with the data I have below, only some respondents provided answers for a second friend. As of now, I am reshaping this data to be long and then trying to remove extraneous cases, i.e., when someone only responded for one friend, because they still get a second row when I reshape for the full dataset. Is there a way to essentially do this within the reshape itself?


    Here is what I am currently doing (in case it's relevant, in the full dataset there are something like 30 variables that are included in the reshape:

    Code:
    reshape long num_drinks_friend yr_attended_friend, i(id) j(friend)
    drop if friend == 2 & multiple_friend == 0 // If they do not respond for multiple friends but have a 2nd friend observation after the reshape

    Some data:
    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input float(id multiple_friends num_drinks_friend1 num_drinks_friend2 yr_attended_friend1 yr_attended_friend2 race_white)
     1 0 3 .    .    . 1
     2 0 3 . 2007    . 1
     3 0 3 . 2010    . 0
     4 0 4 . 2011    . 1
     5 1 5 3 1992 1984 0
     6 0 3 . 2007    . 1
     7 0 3 . 2008    . 1
     8 0 3 . 2012    . 1
     9 1 3 6 2011    . 0
    10 1 4 3 2008 2006 0
    11 0 3 . 2011    . 1
    12 0 4 . 2007    . 1
    13 1 6 3 2012 1981 0
    14 0 3 . 2008    . 1
    15 0 . . 2009    . 1
    16 1 5 5    .    . 0
    17 1 3 5 1992    . 0
    18 0 5 . 2010    . 1
    19 0 3 . 2008    . 1
    20 0 3 . 2008    . 0
    end

  • #2
    No, you can't modify the -reshape- to handle this. The approach you have taken, of dropping the observations that are uninformative, is the way to go.

    Comment

    Working...
    X