----------------------- copy starting from the next line -----------------------
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float uid double(typewatersources_1 typewatersources_2 typewatersources_3 typewatersources_4 distancetosource_1 Roundtriptime_1 waterusage_1_1 waterusage_2_1 waterusage_3_1) 1 1 1 0 0 . . 0 1 1 2 0 0 0 0 . . 1 1 1 3 1 0 0 0 . . 1 1 1 4 0 1 1 0 20 5 0 1 1 5 0 0 0 0 . . 0 1 1 6 0 0 1 0 10 1 0 1 1 7 0 0 0 0 1500 60 1 1 1 8 1 0 0 0 . . 1 1 1 9 1 1 0 0 50 3 1 1 1 10 0 0 0 1 . . 1 1 1 11 0 0 0 0 5 1 1 1 0 12 1 0 0 0 . . 0 0 1 13 1 1 0 0 . . 0 0 1 14 0 0 1 0 5 3 0 0 1 15 0 1 0 0 2 5 1 0 1 16 0 0 0 0 . . 1 0 1 17 0 1 0 0 20 1 1 1 0 18 1 1 0 0 . . 0 0 0 19 1 0 0 0 . . 0 0 1 20 0 1 0 0 5 2 1 0 0 21 0 0 1 0 20 10 1 1 1 22 0 1 0 0 200 1 1 1 0 23 1 0 0 0 . . 1 0 0 24 0 1 0 0 250 30 1 1 1 25 0 1 0 0 30 10 1 1 1 26 1 1 0 0 . . 0 0 0 27 0 0 1 0 20 2 1 0 0 28 0 1 0 0 30 6 1 0 0 29 1 0 0 0 . . 1 0 1 30 1 0 0 0 . . 1 1 0 31 0 0 0 0 100 4 1 1 1 32 0 0 0 0 5 2 1 1 0 33 0 0 0 0 . . 0 1 0 34 0 1 0 0 2 2 1 0 0 35 1 0 0 0 . . 1 0 1 36 0 1 0 0 100 1 1 0 0 37 0 1 0 0 2 3 1 1 1 38 1 1 0 0 . . 1 1 1 39 1 0 0 0 . . 0 1 1 40 0 0 1 0 100 10 1 1 1 41 0 1 0 1 5 2 1 1 1 42 1 0 0 0 . . 1 1 1 43 1 0 0 0 . . 1 0 1 44 0 0 0 0 . . 1 1 1 45 0 0 0 0 15 5 0 1 1 46 1 0 0 0 . . 0 0 1 47 0 1 0 0 50 2 0 0 0 48 0 0 0 0 . . 0 0 1 49 0 0 0 0 200 3 1 1 1 50 1 0 0 0 . . 1 1 0 51 0 1 0 0 300 10 1 1 0 52 1 0 0 0 . . 1 0 1 53 1 0 0 0 . . 1 0 1 54 0 0 0 0 . . 1 0 1 55 1 0 0 0 . . 1 1 1 56 1 0 0 1 . . 1 1 0 57 0 0 0 1 15 200 1 0 0 58 1 1 0 0 . . 0 0 0 59 1 0 0 0 . . 1 1 0 60 0 1 0 0 2 4 1 0 1 61 0 0 1 0 10 2 1 0 0 62 1 1 1 0 . . 1 1 1 63 1 1 0 0 10 10 0 0 0 64 0 1 0 0 100 2 1 1 1 65 1 1 0 0 . . 1 1 0 66 0 1 0 0 100 5 1 1 1 67 1 0 0 0 . . 1 0 0 68 1 0 0 0 . . 1 0 0 69 1 0 0 1 . . 1 1 0 70 0 1 0 0 20 2 1 1 1 71 1 0 0 0 . . 1 1 0 72 0 0 0 1 5 2 1 0 0 73 1 0 0 0 . . 1 0 0 74 0 1 0 0 50 10 1 1 1 75 0 0 0 0 1 1 0 0 1 76 0 1 0 0 100 2 1 0 0 77 1 1 0 0 . . 1 1 1 78 0 0 0 0 20 2 0 0 1 79 1 0 0 0 . . 1 1 1 80 0 0 1 0 30 5 0 0 1 81 1 0 0 0 . . 1 0 0 82 1 0 0 0 . . 1 1 1 83 0 0 0 0 300 40 1 1 1 84 1 0 0 0 . . 1 0 1 85 1 0 0 0 . . 1 1 1 86 0 1 0 0 20 15 1 0 0 87 1 0 0 0 . . 0 1 0 88 0 0 0 0 100 15 1 0 1 89 1 1 0 0 . . 1 1 1 90 1 0 0 0 . . 1 0 1 91 1 1 0 0 . . 0 1 1 92 1 1 0 0 . . 1 1 1 93 1 1 0 0 . . 0 0 0 94 0 0 0 0 . . 1 1 0 95 1 0 0 0 . . 1 0 1 96 1 1 0 0 . . 1 1 0 97 1 1 0 0 . . 1 1 0 98 1 1 0 0 . . 1 1 1 99 1 1 0 0 . . 1 1 1 100 1 0 0 0 . . 1 1 1 end label values typewatersources_1 typewatersources_1 label def typewatersources_1 0 "No", modify label def typewatersources_1 1 "Yes", modify label values typewatersources_2 typewatersources_2 label def typewatersources_2 0 "No", modify label def typewatersources_2 1 "Yes", modify label values typewatersources_3 typewatersources_3 label def typewatersources_3 0 "No", modify label def typewatersources_3 1 "Yes", modify label values typewatersources_4 typewatersources_4 label def typewatersources_4 0 "No", modify label def typewatersources_4 1 "Yes", modify label values waterusage_1_1 waterusage_1_1 label def waterusage_1_1 0 "No", modify label def waterusage_1_1 1 "Yes", modify label values waterusage_2_1 waterusage_2_1 label def waterusage_2_1 0 "No", modify label def waterusage_2_1 1 "Yes", modify label values waterusage_3_1 waterusage_3_1 label def waterusage_3_1 0 "No", modify label def waterusage_3_1 1 "Yes", modify
Hi there,
I am working on reshaping wide to long format and having different levels for different variables. The variable typewatersources has 18 levels, and waterusage_1_, waterusage_2_, and waterusage_3_ have 7 levels, while all other variables have three. I want to reshape the wide-form data like the image attached here. Can I do the reshape with all the variables, or do I need to do it separately for different levels and then merge them?
reshape long typewatersources_ distancetosource_ Roundtriptime_ litrescollected_ paymentperlitre_ queuingtime_ waterusage_1_, waterusage_2_ and waterusage_3_, i(uid) j(sources).
I am mainly having trouble understanding the water usage variables. Please note that each user chooses three water sources from the 18 types and can use water from a given source for up to seven purposes (drinking, cooking, hygiene, etc.). Please help me with the correct commands to make the reshape look like the image. Thanks! I appreciate your help!
Sincerely
Nabittu

Comment