Dear all
This penal data has variable lockdowns related to group time ( quarter& week ) and industry. The variable lockdown just has value in some weeks only and other weeks coded as "0." for example, individual "9100501010102 " in the July-Sep 2020 5 "83" working in Education industry "7" takes the value of lockdown "3.5", whereas, the individual in the time. July-Sep 2020 6 "84" take the value of lockdown "0"
What I want is to replace the value "0" with 3.5." just this for one individual, and I have more than 60000 individuals in my data. This means that I want to replace all the values of lockdown "0" with values in the week after in all my data ( I mean, I need all individuals in week "84" to have the same lockdown value in week "83" if they work in the same industry and so on so forth for all individuals and industries )
I try to use this command, but it takes a lot of time to replace just one week of time in my data
I have more than 25 weeks, and it takes time to do it one by one. Is there any perfect way to do this in Stata?
Thanks
This penal data has variable lockdowns related to group time ( quarter& week ) and industry. The variable lockdown just has value in some weeks only and other weeks coded as "0." for example, individual "9100501010102 " in the July-Sep 2020 5 "83" working in Education industry "7" takes the value of lockdown "3.5", whereas, the individual in the time. July-Sep 2020 6 "84" take the value of lockdown "0"
What I want is to replace the value "0" with 3.5." just this for one individual, and I have more than 60000 individuals in my data. This means that I want to replace all the values of lockdown "0" with values in the week after in all my data ( I mean, I need all individuals in week "84" to have the same lockdown value in week "83" if they work in the same industry and so on so forth for all individuals and industries )
I try to use this command, but it takes a lot of time to replace just one week of time in my data
Code:
replace lockdwon = 8.0 if wdate ==64 & industry1 ==22 replace lockdwon = 27.0 if wdate ==64 & industry1 ==23 replace lockdwon = 81.2 if wdate ==64 & industry1 ==1 replace lockdwon = 7.7 if wdate ==64 & industry1 ==21 replace lockdwon = 5.1 if wdate ==64 & industry1 ==13 replace lockdwon = 3.7 if wdate ==64 & industry1 ==18 replace lockdwon = 9.6 if wdate ==64 & industry1 ==2 replace lockdwon = 13.8 if wdate ==64 & industry1 ==7 replace lockdwon = 3.5 if wdate ==64 & industry1 ==12 replace lockdwon = 82.2 if wdate ==64 & industry1 ==4
Code:
* Example generated by -dataex-. For more info, type help dataex clear input double PERSID float wdate long industry1 double lockdwon 1770203010102 80 7 0 7990493010102 43 12 0 4230191480101 53 14 0 2330794020101 72 12 0 4231191850101 50 14 0 2620693030101 84 23 0 4230101720102 53 12 0 1140293020101 54 18 0 150294010101 41 23 0 2780204070101 132 7 0 2350994050101 48 12 0 181392010102 65 14 22.7 120901020101 100 7 0 660803070101 86 23 0 1321002020101 101 14 6.3 1560102030101 79 5 4.1 7580502010101 83 21 2.2 9380304050101 146 2 0 1410402010103 95 14 8.3 2220491040101 43 14 0 120402020101 69 1 78.1 2291304170101 104 7 0 210501010101 83 23 1.8 9100501010102 83 7 3.5 4230701400101 111 23 29.4 710991040102 61 12 0 1030702020102 111 5 17.4 2450803040101 86 5 0 2000901010102 74 14 0 9141191020102 50 12 0 2240704070101 98 2 0 1540704050102 150 5 0 2031002040101 114 12 0 771392050102 78 7 0 1430502030101 83 5 2.4 2181203020101 90 2 0 490191010102 40 18 0 810604080102 123 1 37.9 1630194020101 92 12 0 2470794010101 85 14 0 7990493010102 56 12 0 710601020102 58 7 0 1690594030101 57 7 0 3040692020102 58 14 0 1250404040101 147 14 3.3 381293030101 90 18 0 671392070101 52 23 0 9061392010102 78 14 0 1051303040102 117 7 34.8 2591092030101 75 18 7.5 4230801600102 86 23 0 1320992020101 74 12 0 2040202030102 80 12 0 1560901020101 61 13 0 4240404390103 134 12 0 2050801020101 112 12 0 1560294030102 80 5 0 4230401960101 95 4 24.2 2171301030102 78 12 0 7890503020102 135 4 6.6 9170791050102 46 18 0 320294020101 41 7 0 490904040101 100 23 0 4230894730101 86 12 0 1130294020101 80 13 0 2390492030101 56 7 0 1030601030102 58 13 0 1420403040101 82 14 0 1920502030101 96 7 0 2181002020103 88 5 0 150104020101 144 23 0 4230292750101 41 18 0 1260801020101 86 18 0 4231104240101 128 13 0 2120594020101 83 5 2.4 110404010102 108 12 0 3081103030101 102 7 0 1320494020101 56 14 0 4230503860102 83 14 0 750904060101 113 13 15 740803020102 112 18 0 371003030102 88 14 0 4230301190101 55 21 0 1910403050103 108 14 0 1591392040102 78 7 0 2950902030102 113 12 19.9 9060793030101 85 12 2.1 2830104070102 131 7 6.5 3000894010101 86 7 0 9020392010101 42 12 0 440394010102 81 18 4.8 1351303010102 104 7 0 551194030101 63 12 0 561103090102 89 13 25.3 1560294030102 41 5 0 4230692240101 58 23 0 1640503020102 83 5 2.4 2820603080102 110 5 0 390401030101 82 14 0 1121103020102 89 23 6 end label values wdate wdate label def wdate 40 "Oct-Des 2019 1", modify label def wdate 41 "Oct-Des 2019 2", modify label def wdate 42 "Oct-Des 2019 3", modify label def wdate 43 "Oct-Des 2019 4", modify label def wdate 46 "Oct-Des 2019 7", modify label def wdate 48 "Oct-Des 2019 9", modify label def wdate 50 "Oct-Des 2019 11", modify label def wdate 52 "Oct-Des 2019 13", modify label def wdate 53 "Jan-Mar 2020 1", modify label def wdate 54 "Jan-Mar 2020 2", modify label def wdate 55 "Jan-Mar 2020 3", modify label def wdate 56 "Jan-Mar 2020 4", modify label def wdate 57 "Jan-Mar 2020 5", modify label def wdate 58 "Jan-Mar 2020 6", modify label def wdate 61 "Jan-Mar 2020 9", modify label def wdate 63 "Jan-Mar 2020 11", modify label def wdate 65 "Jan-Mar 2020 13", modify label def wdate 69 "Apr-June 2020 4", modify label def wdate 72 "Apr-June 2020 7", modify label def wdate 74 "Apr-June 2020 9", modify label def wdate 75 "Apr-June 2020 10", modify label def wdate 78 "Apr-June 2020 13", modify label def wdate 79 "July-Sep 2020 1", modify label def wdate 80 "July-Sep 2020 2", modify label def wdate 81 "July-Sep 2020 3", modify label def wdate 82 "July-Sep 2020 4", modify label def wdate 83 "July-Sep 2020 5", modify label def wdate 84 "July-Sep 2020 6", modify label def wdate 85 "July-Sep 2020 7", modify label def wdate 86 "July-Sep 2020 8", modify label def wdate 88 "July-Sep 2020 10", modify label def wdate 89 "July-Sep 2020 11", modify label def wdate 90 "July-Sep 2020 12", modify label def wdate 92 "Oct-Des 2020 1", modify label def wdate 95 "Oct-Des 2020 4", modify label def wdate 96 "Oct-Des 2020 5", modify label def wdate 98 "Oct-Des 2020 7", modify label def wdate 100 "Oct-Des 2020 9", modify label def wdate 101 "Oct-Des 2020 10", modify label def wdate 102 "Oct-Des 2020 11", modify label def wdate 104 "Oct-Des 2020 13", modify label def wdate 108 "Jan-Mar 2021 4", modify label def wdate 110 "Jan-Mar 2021 6", modify label def wdate 111 "Jan-Mar 2021 7", modify label def wdate 112 "Jan-Mar 2021 8", modify label def wdate 113 "Jan-Mar 2021 9", modify label def wdate 114 "Jan-Mar 2021 10", modify label def wdate 117 "Jan-Mar 2021 13", modify label def wdate 123 "Apr-June 2021 6", modify label def wdate 128 "Apr-June 2021 11", modify label def wdate 131 "July-Sep 2021 1", modify label def wdate 132 "July-Sep 2021 2", modify label def wdate 134 "July-Sep 2021 4", modify label def wdate 135 "July-Sep 2021 5", modify label def wdate 144 "Oct-Des 2021 1", modify label def wdate 146 "Oct-Des 2021 3", modify label def wdate 147 "Oct-Des 2021 4", modify label def wdate 150 "Oct-Des 2021 7", modify label values industry1 industry label def industry 1 "Accommodation And Food Service Activities", modify label def industry 2 "Administrative And Support Service Activities", modify label def industry 4 "Arts, Entertainment And Recreation", modify label def industry 5 "Construction", modify label def industry 7 "Education", modify label def industry 12 "Human Health And Social Work Activities", modify label def industry 13 "Information And Communication", modify label def industry 14 "Manufacturing", modify label def industry 18 "Professional, Scientific And Technical Activities", modify label def industry 21 "Transportation And Storage", modify label def industry 23 "Wholesale And Retail Trade; Repair Of Motor Vehicles And Motorcycles", modify
Thanks
Comment