Dear all,
I've two datasets:
The first data is quarterly panel data.
The second is (Trade data )
This is the panel data:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input double PERSID byte(quarter WEEK) float(qdate wdate) str68 industry 10101010101 5 1 240 53 "Does not apply" 10101010101 6 1 241 66 "Public admin and defence" 10101010101 7 1 242 79 "Does not apply" 10101010101 8 1 243 92 "Other service activities" 10101010101 9 1 244 105 "Information And Communication" 10101010102 5 1 240 53 "Does not apply" 10101010102 6 1 241 66 "Does not apply" 10101010102 7 1 242 79 "Does not apply" 10101010102 8 1 243 92 "Does not apply" 10101010102 9 1 244 105 "Does not apply" 10102020102 6 1 241 66 "Education" 10102020102 7 1 242 79 "Education" 10102020102 8 1 243 92 "Education" 10102020102 9 1 244 105 "Education" 10102020102 10 1 245 118 "Education" 10104030101 8 1 243 92 "Human Health And Social Work Activities" 10104030101 9 1 244 105 "Human Health And Social Work Activities" 10104030101 10 1 245 118 "Human Health And Social Work Activities" 10104030101 11 1 246 131 "Human Health And Social Work Activities" 10104030101 12 1 247 144 "Human Health And Social Work Activities" 10104030102 8 1 243 92 "Human Health And Social Work Activities" 10104030102 9 1 244 105 "Human Health And Social Work Activities" 10104030102 10 1 245 118 "Human Health And Social Work Activities" 10104030102 11 1 246 131 "Human Health And Social Work Activities" 10104030102 12 1 247 144 "Human Health And Social Work Activities" 10203030101 7 2 242 80 "Wholesale And Retail Trade; Repair Of Motor Vehicles And Motorcycles" 10203030101 8 2 243 93 "Wholesale And Retail Trade; Repair Of Motor Vehicles And Motorcycles" 10203030101 9 2 244 106 "Wholesale And Retail Trade; Repair Of Motor Vehicles And Motorcycles" 10203030101 10 2 245 119 "Wholesale And Retail Trade; Repair Of Motor Vehicles And Motorcycles" 10203030101 11 2 246 132 "Wholesale And Retail Trade; Repair Of Motor Vehicles And Motorcycles" 10303030101 7 3 242 81 "Professional, Scientific And Technical Activities" 10303030101 8 3 243 94 "Professional, Scientific And Technical Activities" 10303030101 9 3 244 107 "Professional, Scientific And Technical Activities" 10303030101 10 3 245 120 "Professional, Scientific And Technical Activities" 10303030101 11 3 246 133 "Professional, Scientific And Technical Activities" 10304050102 8 3 243 94 "Manufacturing" 10304050102 9 3 244 107 "Does not apply" 10304050102 10 3 245 120 "Does not apply" 10304050102 11 3 246 133 "Does not apply" 10304050102 12 3 247 146 "Does not apply" 10493040101 3 4 238 30 "Does not apply" 10493040101 4 4 239 43 "Does not apply" 10493040101 5 4 240 56 "Does not apply" 10493040101 6 4 241 69 "Does not apply" 10493040101 7 4 242 82 "Does not apply" 10501030101 5 5 240 57 "Professional, Scientific And Technical Activities" 10501030101 6 5 241 70 "Professional, Scientific And Technical Activities" 10501030101 7 5 242 83 "Professional, Scientific And Technical Activities" 10501030101 8 5 243 96 "Professional, Scientific And Technical Activities" 10501030101 9 5 244 109 "Professional, Scientific And Technical Activities" 10504040102 9 5 244 109 "Does not apply" 10504040102 10 5 245 122 "Does not apply" 10504040102 11 5 246 135 "Does not apply" 10504040102 12 5 247 148 "Does not apply" 10602010101 6 6 241 71 "Does not apply" 10602010101 7 6 242 84 "Does not apply" 10602010101 8 6 243 97 "Does not apply" 10602010101 9 6 244 110 "Does not apply" 10602010101 10 6 245 123 "Does not apply" 10602020101 6 6 241 71 "Wholesale And Retail Trade; Repair Of Motor Vehicles And Motorcycles" 10602020101 7 6 242 84 "Wholesale And Retail Trade; Repair Of Motor Vehicles And Motorcycles" 10602020101 8 6 243 97 "Wholesale And Retail Trade; Repair Of Motor Vehicles And Motorcycles" 10602020101 9 6 244 110 "Wholesale And Retail Trade; Repair Of Motor Vehicles And Motorcycles" 10602020101 10 6 245 123 "Wholesale And Retail Trade; Repair Of Motor Vehicles And Motorcycles" 10603070101 7 6 242 84 "Real estate activit ies" 10603070101 8 6 243 97 "Real estate activit ies" 10603070101 9 6 244 110 "Real estate activit ies" 10603070101 10 6 245 123 "Does not apply" 10603070101 11 6 246 136 "Real estate activit ies" 10604060102 8 6 243 97 "Human Health And Social Work Activities" end format %tq qdate label values quarter quarter label def quarter 3 "July-Sep 2019", modify label def quarter 4 "Oct-Des 2019", modify label def quarter 5 "Jan-Mar 2020", modify label def quarter 6 "Apr-June 2020", modify label def quarter 7 "July-Sep 2020", modify label def quarter 8 "Oct-Des 2020", modify label def quarter 9 "Jan-Mar 2021", modify label def quarter 10 "Apr-June 2021", modify label def quarter 11 "July-Sep 2021", modify label def quarter 12 "Oct-Des 2021", modify label values WEEK WEEK label values wdate wdate label def wdate 30 "July-Sep 2019 4", modify label def wdate 43 "Oct-Des 2019 4", modify label def wdate 45 "Oct-Des 2019 6", modify label def wdate 53 "Jan-Mar 2020 1", 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 66 "Apr-June 2020 1", modify label def wdate 69 "Apr-June 2020 4", modify label def wdate 70 "Apr-June 2020 5", modify label def wdate 71 "Apr-June 2020 6", 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 92 "Oct-Des 2020 1", modify label def wdate 93 "Oct-Des 2020 2", modify label def wdate 94 "Oct-Des 2020 3", modify label def wdate 96 "Oct-Des 2020 5", modify label def wdate 97 "Oct-Des 2020 6", modify label def wdate 105 "Jan-Mar 2021 1", modify label def wdate 106 "Jan-Mar 2021 2", modify label def wdate 107 "Jan-Mar 2021 3", modify label def wdate 109 "Jan-Mar 2021 5", modify label def wdate 110 "Jan-Mar 2021 6", modify label def wdate 118 "Apr-June 2021 1", modify label def wdate 119 "Apr-June 2021 2", modify label def wdate 120 "Apr-June 2021 3", modify label def wdate 122 "Apr-June 2021 5", modify label def wdate 123 "Apr-June 2021 6", modify label def wdate 131 "July-Sep 2021 1", modify label def wdate 132 "July-Sep 2021 2", modify label def wdate 133 "July-Sep 2021 3", modify label def wdate 135 "July-Sep 2021 5", modify label def wdate 136 "July-Sep 2021 6", modify label def wdate 144 "Oct-Des 2021 1", modify label def wdate 146 "Oct-Des 2021 3", modify label def wdate 148 "Oct-Des 2021 5", modify label def wdate 149 "Oct-Des 2021 6", modify
The panel data contains the time variable "quarter". Also, the week variable in which the week interview was conducted "WEEk". Also, the industry sector variable is "industry" but this variable is a factor variable, and it contains all industries (for example, manufacturing, accommodation … ..etc.) ranging from 1 to 9. In other words, the manufacturing industry takes the value "1", the accommodation industry takes the value "2" ... etc.
Note that when creating a quarter variable, I assigned, for example, 4 to the 4th quarter of 2019. this means that I also assigned 3 to the third quarter of 2019, and 5 to the first quarter of 2020, and so on, using consecutive numbers in the same order as the quarters themselves.
This is the Trade data:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str24 date str68 industry str5 hastemporarilyclosedortemporaril float(period_start period_finish) "23/03/2020 to 05/04/2020" "Manufacturing" "22.7%" 21997 22010 "23/03/2020 to 05/04/2020" "Water Supply, Sewerage, Waste Management And Remediation Activities" "8.0%" 21997 22010 "23/03/2020 to 05/04/2020" "Construction" "29.1%" 21997 22010 "23/03/2020 to 05/04/2020" "Wholesale And Retail Trade; Repair Of Motor Vehicles And Motorcycles" "27.0%" 21997 22010 "23/03/2020 to 05/04/2020" "Accommodation And Food Service Activities" "81.2%" 21997 22010 "23/03/2020 to 05/04/2020" "Transportation And Storage" "7.7%" 21997 22010 "23/03/2020 to 05/04/2020" "Information And Communication" "5.1%" 21997 22010 "23/03/2020 to 05/04/2020" "Professional, Scientific And Technical Activities" "3.7%" 21997 22010 "23/03/2020 to 05/04/2020" "Administrative And Support Service Activities" "9.6%" 21997 22010 "23/03/2020 to 05/04/2020" "Education" "13.8%" 21997 22010 "23/03/2020 to 05/04/2020" "Human Health And Social Work Activities" "3.5%" 21997 22010 "23/03/2020 to 05/04/2020" "Arts, Entertainment And Recreation" "82.2%" 21997 22010 "23/03/2020 to 05/04/2020" "All Industries" "24.3%" 21997 22010 "06/04/2020 to 19/04/2020" "Manufacturing" "20.6%" 22011 22024 "06/04/2020 to 19/04/2020" "Water Supply, Sewerage, Waste Management And Remediation Activities" "10.0%" 22011 22024 "06/04/2020 to 19/04/2020" "Construction" "26.1%" 22011 22024 "06/04/2020 to 19/04/2020" "Wholesale And Retail Trade; Repair Of Motor Vehicles And Motorcycles" "24.3%" 22011 22024 "06/04/2020 to 19/04/2020" "Accommodation And Food Service Activities" "80.6%" 22011 22024 "06/04/2020 to 19/04/2020" "Transportation And Storage" "8.5%" 22011 22024 "06/04/2020 to 19/04/2020" "Information And Communication" "4.5%" 22011 22024 "06/04/2020 to 19/04/2020" "Professional, Scientific And Technical Activities" "3.0%" 22011 22024 "06/04/2020 to 19/04/2020" "Administrative And Support Service Activities" "8.1%" 22011 22024 "06/04/2020 to 19/04/2020" "Education" "12.6%" 22011 22024 "06/04/2020 to 19/04/2020" "Human Health And Social Work Activities" "4.9%" 22011 22024 "06/04/2020 to 19/04/2020" "Arts, Entertainment And Recreation" "79.5%" 22011 22024 "06/04/2020 to 19/04/2020" "All Industries" "22.8%" 22011 22024 "20/04/2020 to 03/05/2020" "Manufacturing" "13.9%" 22025 22038 "20/04/2020 to 03/05/2020" "Water Supply, Sewerage, Waste Management And Remediation Activities" "2.9%" 22025 22038 "20/04/2020 to 03/05/2020" "Construction" "21.6%" 22025 22038 "20/04/2020 to 03/05/2020" "Wholesale And Retail Trade; Repair Of Motor Vehicles And Motorcycles" "20.0%" 22025 22038 "20/04/2020 to 03/05/2020" "Transportation And Storage" "5.0%" 22025 22038 "20/04/2020 to 03/05/2020" "Accommodation And Food Service Activities" "78.1%" 22025 22038 "20/04/2020 to 03/05/2020" "Information And Communication" "4.5%" 22025 22038 "20/04/2020 to 03/05/2020" "Real Estate Activities" "5.6%" 22025 22038 "20/04/2020 to 03/05/2020" "Professional, Scientific And Technical Activities" "3.4%" 22025 22038 "20/04/2020 to 03/05/2020" "Administrative And Support Service Activities" "7.1%" 22025 22038 "20/04/2020 to 03/05/2020" "Education" "9.8%" 22025 22038 "20/04/2020 to 03/05/2020" "Human Health And Social Work Activities" "3.8%" 22025 22038 "20/04/2020 to 03/05/2020" "Arts, Entertainment And Recreation" "80.1%" 22025 22038 "20/04/2020 to 03/05/2020" "All Industries" "20.3%" 22025 22038 "04/05/2020 to 17/05/2020" "Manufacturing" "7.4%" 22039 22052 "04/05/2020 to 17/05/2020" "Water Supply, Sewerage, Waste Management And Remediation Activities" "4.5%" 22039 22052 "04/05/2020 to 17/05/2020" "Information And Communication" "5.8%" 22039 22052 "04/05/2020 to 17/05/2020" "Real Estate Activities" "2.9%" 22039 22052 "04/05/2020 to 17/05/2020" "Professional, Scientific And Technical Activities" "2.6%" 22039 22052 "04/05/2020 to 17/05/2020" "Administrative And Support Service Activities" "8.6%" 22039 22052 "04/05/2020 to 17/05/2020" "Education" "9.4%" 22039 22052 "04/05/2020 to 17/05/2020" "Human Health And Social Work Activities" "3.3%" 22039 22052 "04/05/2020 to 17/05/2020" "Arts, Entertainment And Recreation" "74.6%" 22039 22052 "04/05/2020 to 17/05/2020" "All Industries" "17.7%" 22039 22052 "18/05/2020 to 31/05/2020" "Manufacturing" "4.8%" 22053 22066 "18/05/2020 to 31/05/2020" "Water Supply, Sewerage, Waste Management And Remediation Activities" "0.0%" 22053 22066 "18/05/2020 to 31/05/2020" "Construction" "17.0%" 22053 22066 "18/05/2020 to 31/05/2020" "Wholesale And Retail Trade; Repair Of Motor Vehicles And Motorcycles" "11.5%" 22053 22066 "18/05/2020 to 31/05/2020" "Transportation And Storage" "4.0%" 22053 22066 "18/05/2020 to 31/05/2020" "Accommodation And Food Service Activities" "65.3%" 22053 22066 "18/05/2020 to 31/05/2020" "Information And Communication" "4.8%" 22053 22066 "18/05/2020 to 31/05/2020" "Real Estate Activities" "4.8%" 22053 22066 "18/05/2020 to 31/05/2020" "Professional, Scientific And Technical Activities" "2.4%" 22053 22066 "18/05/2020 to 31/05/2020" "Administrative And Support Service Activities" "8.7%" 22053 22066 "18/05/2020 to 31/05/2020" "Education" "10.4%" 22053 22066 "18/05/2020 to 31/05/2020" "Human Health And Social Work Activities" "4.5%" 22053 22066 "18/05/2020 to 31/05/2020" "Arts, Entertainment And Recreation" "69.8%" 22053 22066 "18/05/2020 to 31/05/2020" "All Industries" "15.5%" 22053 22066 "01/06/2020 to 14/06/2020" "Manufacturing" "2.6%" 22067 22080 "01/06/2020 to 14/06/2020" "Water Supply, Sewerage, Waste Management And Remediation Activities" "1.5%" 22067 22080 "01/06/2020 to 14/06/2020" "Construction" "12.0%" 22067 22080 "01/06/2020 to 14/06/2020" "Real Estate Activities" "2.8%" 22067 22080 "01/06/2020 to 14/06/2020" "Professional, Scientific And Technical Activities" "7.5%" 22067 22080 "01/06/2020 to 14/06/2020" "Administrative And Support Service Activities" "11.8%" 22067 22080 "01/06/2020 to 14/06/2020" "Education" "10.5%" 22067 22080 "01/06/2020 to 14/06/2020" "Human Health And Social Work Activities" "4.1%" 22067 22080 "01/06/2020 to 14/06/2020" "Arts, Entertainment And Recreation" "58.6%" 22067 22080 "01/06/2020 to 14/06/2020" "All Industries" "13.5%" 22067 22080 end format %td period_start format %td period_finish
The Trade data has 19 waves of how Covid-19 affected the industry (% of Lockdown) in the labour market (each wave constitutes two weeks) containing divisions of the variable "industry" and coded as a percentage.
The definition of the week in the panel data is as follows:
First quarter of 2020
The first week of the quarter is Week 1, which starts on Wednesday, January 1, 2020, and ends on Tuesday, January 7, 2020. The last week of the quarter is Week 13, which starts on Wednesday, March 25, 2019, and ends on Tuesday, March 31, 2020
Second quarter of 2020
The first week of the quarter is Week 1, which starts on Wednesday, April 1, 2020, and ends on Tuesday, April 7, 2020. The last week of the quarter is Week 13, which starts on Wednesday, June 24, 2020, and ends on Tuesday, June 30, 2020.
And we apply the same way for all subsequent quarters.
The 13-week reference period is based on a rolling reference period, which means that each reference week is the same week in the quarter, regardless of the year. For example, the first reference week of the first quarter is always the first week of January, and the first reference week of the second quarter is always the first week of April.
In this case, we mapped it to 13 weeks per quarter. Assume that the quarter is always 13 weeks. So, I generated this variable.
Code:
egen wdate = group(quarter week), label
So, I used these codes to merge the datasets:
Code:
// IDENTIFY START AND FINISH DATES OF EACH "WEEK" use `dataset1', clear gen week_start = dofq(qdate) + (WEEK-1)*7 gen week_finish = /// cond(WEEK == 13, dofq(qdate+1)-1, week_start + 6) format week_start week_finish %td tempfile dataset1_modified gen `c(obs_t)' obs_no = _n save `dataset1_modified' // EXTRACT START AND FINISH DATES OF EACH PERIOD use `dataset2', clear gen period_start = daily(substr(date, 1, 10), "DMY") assert missing(period_start) == missing(date) gen period_finish = daily(substr(date, 15, 10), "DMY") assert missing(period_finish) == missing(date) format period_start period_finish %td // MATCH ALL PAIRS OF OBSERVATIONS WHERE THE "WEEK" IS COMPLETELY // CONTAINED WITHIN THE PERIOD joinby industry using `dataset1_modified', drop if (week_finish > period_finish | week_start < period_start) merge m:1 obs_no using `dataset1_modified', assert(match using) nogenerate
Code:
* Example generated by -dataex-. For more info, type help dataex clear input double PERSID byte(quarter WEEK) float(qdate wdate) long industry1 double lockdwon 1770203010102 7 2 242 80 7 0 7990493010102 4 4 239 43 12 0 4230191480101 5 1 240 53 14 0 2330794020101 6 7 241 72 12 0 4231191850101 4 11 239 50 14 0 2620693030101 7 6 242 84 23 0 4230101720102 5 1 240 53 12 0 1140293020101 5 2 240 54 18 0 150294010101 4 2 239 41 23 0 2780204070101 11 2 246 132 7 0 2350994050101 4 9 239 48 12 0 181392010102 5 13 240 65 14 22.7 120901020101 8 9 243 100 7 0 660803070101 7 8 242 86 23 0 1321002020101 8 10 243 101 14 6.3 1560102030101 7 1 242 79 5 4.1 7580502010101 7 5 242 83 21 2.2 9380304050101 12 3 247 146 2 0 1410402010103 8 4 243 95 14 8.3 2220491040101 4 4 239 43 14 0 120402020101 6 4 241 69 1 78.1 2291304170101 8 13 243 104 7 0 210501010101 7 5 242 83 23 1.8 9100501010102 7 5 242 83 7 3.5 4230701400101 9 7 244 111 23 29.4 710991040102 5 9 240 61 12 0 1030702020102 9 7 244 111 5 17.4 2450803040101 7 8 242 86 5 0 2000901010102 6 9 241 74 14 0 9141191020102 4 11 239 50 12 0 2240704070101 8 7 243 98 2 0 1540704050102 12 7 247 150 5 0 2031002040101 9 10 244 114 12 0 771392050102 6 13 241 78 7 0 1430502030101 7 5 242 83 5 2.4 2181203020101 7 12 242 90 2 0 490191010102 4 1 239 40 18 0 810604080102 10 6 245 123 1 37.9 1630194020101 8 1 243 92 12 0 2470794010101 7 7 242 85 14 0 7990493010102 5 4 240 56 12 0 710601020102 5 6 240 58 7 0 1690594030101 5 5 240 57 7 0 3040692020102 5 6 240 58 14 0 1250404040101 12 4 247 147 14 3.3 381293030101 7 12 242 90 18 0 671392070101 4 13 239 52 23 0 9061392010102 6 13 241 78 14 0 1051303040102 9 13 244 117 7 34.8 2591092030101 6 10 241 75 18 7.5 4230801600102 7 8 242 86 23 0 1320992020101 6 9 241 74 12 0 2040202030102 7 2 242 80 12 0 1560901020101 5 9 240 61 13 0 4240404390103 11 4 246 134 12 0 2050801020101 9 8 244 112 12 0 1560294030102 7 2 242 80 5 0 4230401960101 8 4 243 95 4 24.2 2171301030102 6 13 241 78 12 0 7890503020102 11 5 246 135 4 6.6 9170791050102 4 7 239 46 18 0 320294020101 4 2 239 41 7 0 490904040101 8 9 243 100 23 0 4230894730101 7 8 242 86 12 0 1130294020101 7 2 242 80 13 0 2390492030101 5 4 240 56 7 0 1030601030102 5 6 240 58 13 0 1420403040101 7 4 242 82 14 0 1920502030101 8 5 243 96 7 0 2181002020103 7 10 242 88 5 0 150104020101 12 1 247 144 23 0 4230292750101 4 2 239 41 18 0 1260801020101 7 8 242 86 18 0 4231104240101 10 11 245 128 13 0 2120594020101 7 5 242 83 5 2.4 110404010102 9 4 244 108 12 0 3081103030101 8 11 243 102 7 0 1320494020101 5 4 240 56 14 0 4230503860102 7 5 242 83 14 0 end format %tq qdate label values quarter quarter label def quarter 4 "Oct-Des 2019", modify label def quarter 5 "Jan-Mar 2020", modify label def quarter 6 "Apr-June 2020", modify label def quarter 7 "July-Sep 2020", modify label def quarter 8 "Oct-Des 2020", modify label def quarter 9 "Jan-Mar 2021", modify label def quarter 10 "Apr-June 2021", modify label def quarter 11 "July-Sep 2021", modify label def quarter 12 "Oct-Des 2021", modify label values WEEK WEEK 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
After merging, I faced the problem that the “Lockdown” variable contained a lot of zero values because the "trade data" is two weeks time, so when we matched with the panel data variable, there are around 7 weeks in each quarter that have no information about the lockdown. ( these weeks are the week between; for example, trade data 23/03/ 2020 to 05 /04/2020 is matched one week with real value in panel data and give a "0" value for the second week.)
So, I need to decide what to do with the weeks in between. Therefore, I can assume the week between is the same value as the one before. I want to fill in the weeks with no actual value so they have the same value as the previous week.
In the end, the final form of the Trade date will be as follows:
For example, The first week: 23/03/2020 to 29/03/2020 , manufacturing, Lockdown 22.7%
The second week:30/03/2020 to 05/04/2020, manufacturing, Lockdown 22.7 %
So, the value of the second week is the same value as the first week.
I don't know how to do this in Stata. Can I fix this in the final data ( the ready data ) ? or should we do something before merging data? How to do this?
I really appreciate your advice and waiting for your help.