I have 2 years datasets (2007 and 2009) which has information on household food borrowing networks. In 2007 and 2009, households were asked to report up to 3 household ids from which they borrow food from. My dataset is in the wide-format and food_borrow_netid1-food_borrow_netid3 are the three network ids the household reports borrowing food from.
I want to create a variable broken_link with the following rules:
1) takes the value of 1 if food_borrow_netid is mentioned in 2007 (any of the three mentioned ids) but not in 2009 (any of the 3 mentioned ids)
2) takes the value of 0 if the food_borrow_netid is mentioned in both 2007 and 2009
3) It will also be interesting to have a variable that counts the total number of links maintained.
Any help in this regard will be highly appreciated
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input byte branchid int(spotno hhno year food_borrow_netid1 food_borrow_netid2 food_borrow_netid3) 1 1 46 2007 45 . . 1 1 46 2009 205 44 45 1 1 57 2007 56 . . 1 1 57 2009 202 93 47 1 1 85 2007 77 76 78 1 1 85 2009 86 21 90 1 1 86 2007 77 . . 1 1 86 2009 16 77 87 1 1 87 2007 77 . . 1 2 6 2007 4 . . 1 2 6 2009 1 5 4 1 2 26 2007 23 24 25 1 2 26 2009 23 24 25 1 2 30 2007 31 . . 1 2 30 2009 30 31 36 1 2 36 2007 39 . . 1 2 36 2009 36 37 39 1 2 39 2007 38 . . 1 2 39 2009 38 40 37 1 2 54 2007 210 211 . 1 2 54 2009 50 55 56 1 2 80 2007 60 . . 1 2 80 2009 60 81 83 1 3 6 2009 10 11 13 1 3 9 2009 7 11 12 1 3 16 2009 14 15 13 1 3 17 2009 15 14 13 1 3 27 2009 21 24 20 1 3 41 2007 36 49 50 1 3 41 2009 36 49 40 1 3 46 2007 49 50 63 1 3 46 2009 49 50 63 1 3 47 2007 48 49 50 1 3 47 2009 48 49 50 1 3 51 2007 53 56 60 1 3 51 2009 53 65 60 1 3 52 2009 49 50 53 1 3 78 2009 77 82 81 1 3 98 2007 101 102 104 1 3 98 2009 93 94 2 1 4 2 2007 6 . . 1 4 12 2007 13 14 15 1 4 17 2007 12 . . 1 4 17 2009 14 15 16 1 4 33 2007 28 24 30 1 4 33 2009 37 32 30 1 4 34 2007 35 36 . 1 4 34 2009 35 36 31 1 4 44 2007 43 . 45 1 4 44 2009 43 46 45 1 4 46 2007 43 44 45 1 4 46 2009 46 45 44 1 4 51 2007 53 54 55 1 4 51 2009 53 54 55 1 4 56 2007 57 58 . 1 4 56 2009 54 55 57 1 4 64 2007 60 . . 1 4 71 2007 74 . . 1 4 71 2009 20 69 67 1 4 78 2007 77 74 . 1 4 78 2009 77 79 81 1 4 83 2007 82 77 78 1 4 83 2009 82 77 78 1 4 86 2007 118 . . 1 4 86 2009 118 90 89 1 4 90 2007 88 . . 1 4 90 2009 89 88 91 1 4 110 2009 73 111 112 1 4 120 2007 116 117 . 1 4 120 2009 116 112 111 1 4 130 2007 128 . . 1 4 130 2009 128 126 127 1 4 131 2007 134 135 . 1 4 131 2009 136 139 138 1 5 16 2009 17 18 28 1 5 24 2009 25 26 27 1 5 32 2007 28 29 . 1 5 32 2009 31 33 34 1 5 35 2007 36 38 . 1 5 35 2009 37 38 34 1 5 56 2009 57 58 67 1 5 76 2009 75 77 78 1 6 1 2009 5 7 15 1 6 2 2009 5 3 4 1 6 6 2009 4 7 15 1 6 9 2007 10 28 8 1 6 17 2009 15 16 18 1 6 36 2009 35 37 39 1 6 38 2009 36 37 39 1 6 47 2009 46 45 50 1 6 48 2009 202 203 47 1 6 52 2009 53 54 50 1 6 54 2009 57 61 62 1 6 61 2009 60 56 62 1 6 90 2009 88 86 85 1 7 6 2009 15 16 14 1 7 16 2009 15 17 18 1 7 27 2007 26 . . 1 7 27 2009 26 28 29 1 7 36 2007 34 35 . end
0 Response to Making a variable for one year from information present in both years
Post a Comment