Dear all,
I have quarterly panel data. I want to merge external data related to a factor variable in the panel data.
This is the panel data:
it contains the time variable "quarter" and also the week variable in which the week interview was conducted "WEEk" and also the industry sector in the main job variable "Inde07m "but this variable is a factor variable, and it contains all industry (for example manufacturing, accommodation … ..etc.) its range from 1 to 9, in other words, manufacturing industry takes the value "1", the accommodation industry takes the value "2" ... etc.
The external data is:
It has six waves of how Covid-19 affected the industry in the labour market (each wave constitutes two weeks) containing divisions of the variable "Inde07m" and coded as a percentage : continuing to trade , or permanently ceased trading ,or temporarily paused trading during the covid-19.
I want to combine this external data based on time and industry. In other words, I want to get a column in the data after the merge, saying that the manufacturing industry was temporarily paused trading from April 20 to May 3, and so forth.
I'm a new user of Stata. What is the best way to merge these two datasets? Could we solve this directly from the merge, and how can we do that? Or must you code the data differently before merging?
I appreciate any contribution to solving this problem.
I have quarterly panel data. I want to merge external data related to a factor variable in the panel data.
This is the panel data:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input double PERSID byte(quarter WEEK Inde07m FLEXW7 FTPT SEX) 9311094030103 4 10 5 1 2 2 4230193290101 4 1 5 1 1 2 1181393020101 4 13 5 1 2 2 1151093050101 4 10 3 1 1 1 661193020101 4 11 8 1 1 1 9090791010103 4 7 5 1 1 1 7970793020101 4 7 8 1 2 2 261391010102 4 13 8 1 2 2 1140193040101 4 1 7 1 2 1 2710693020101 4 6 5 1 1 1 2261291010104 4 12 6 1 2 2 4230294810101 4 2 8 1 1 2 1730191030101 4 1 5 1 2 2 1401194030101 4 11 8 1 2 2 2130193020102 4 1 3 1 1 2 2160593050101 4 5 9 1 2 2 1041091010101 4 10 8 1 2 2 860793030101 4 7 9 1 1 2 1810393060101 4 3 8 1 2 2 3020193040104 4 1 5 1 1 2 1310693010101 4 6 8 1 2 2 1401291010101 4 12 8 1 2 2 751394020103 4 13 8 1 2 2 4231091250101 4 10 7 1 2 2 4231393710102 4 13 6 1 1 1 3021293020101 4 12 8 1 2 2 4230594570102 4 5 5 1 2 2 2330894010102 4 8 8 1 1 2 2020293040102 4 2 8 1 2 2 2161093020101 4 10 3 1 2 1 1001193010101 4 11 9 1 2 2 1460891040101 4 8 7 1 1 1 21391010101 4 13 5 1 1 2 2140991040102 4 9 5 1 2 2 1620193010101 4 1 8 1 2 1 880393050101 4 3 8 1 2 1 710493030102 4 4 8 1 2 2 4231094200102 4 10 5 1 1 2 2850394040102 4 3 8 1 2 2 650293050102 4 2 7 1 1 1 9081393010102 4 13 4 1 1 1 3121393010101 4 13 4 1 1 1 7760993010101 4 9 8 1 1 2 1061291020101 4 12 8 1 2 1 751394020105 4 13 8 1 2 1 2840593030103 4 5 6 1 1 2 2060393030102 4 3 6 1 2 1 3020293010103 4 2 5 1 2 1 101091030102 4 10 5 1 1 1 2550393040101 4 3 4 1 1 1 9340991010102 4 9 6 1 2 1 2190491010101 4 4 3 1 2 2 2840491030103 4 4 8 1 2 2 3090494010101 4 4 8 1 2 1 7731291010102 4 12 8 1 2 2 641093010101 4 10 6 1 1 1 121294040101 4 12 5 1 2 1 980691030103 4 6 9 1 2 2 910793010101 4 7 8 1 2 2 850791040101 4 7 6 1 1 2 7570893010101 4 8 7 1 2 1 1601091040103 4 10 5 1 2 1 1530593060102 4 5 5 1 2 2 40593010104 4 5 7 1 2 2 880991010102 4 9 7 1 1 2 9081393010101 4 13 7 1 1 2 1601091040102 4 10 8 1 1 2 1560793020101 4 7 8 1 2 2 1581191010102 4 11 5 1 2 2 1071394030101 4 13 8 1 2 2 4230193620102 4 1 6 1 2 2 1170891040101 4 8 7 1 2 1 340291010101 4 2 8 1 2 2 330894040102 4 8 8 1 2 2 1140193050103 4 1 8 1 2 1 3090293020101 4 2 8 1 2 2 9180394010101 4 3 7 1 1 1 160593020101 4 5 8 1 2 2 9360193020101 4 1 8 1 2 2 1741093010101 4 10 8 1 2 2 951191110101 4 11 5 1 2 1 1461094030102 4 10 9 1 2 1 100191010103 4 1 5 1 2 2 1951394010101 4 13 9 1 2 1 310293030101 4 2 8 1 2 2 1210791010103 4 7 7 1 2 1 341094010103 4 10 9 1 2 1 1270591020101 4 5 8 1 2 2 9280491010101 4 4 8 1 2 1 540691030102 4 6 1 1 1 1 7821393020103 4 13 3 1 2 1 270491040101 4 4 7 1 2 1 2141193020101 4 11 5 1 1 1 1450691020104 4 6 5 1 2 1 4230591290102 4 5 9 1 2 1 230991010102 4 9 7 1 2 2 1611391010101 4 13 5 1 1 2 150593020104 4 5 5 1 2 2 4231193360103 4 11 5 1 2 2 2661093010101 4 10 8 1 1 2 end label values quarter quarter label def quarter 4 "Oct-Des 2019", modify label values WEEK WEEK label values Inde07m Inde07m5 label def Inde07m5 1 "A - Agriculture, forestry and fishing", modify label def Inde07m5 3 "C -Manufacturing", modify label def Inde07m5 4 "F - Construction", modify label def Inde07m5 5 "G,I -Distribution, hotels and restaurants", modify label def Inde07m5 6 "H,J -Transport and communication", modify label def Inde07m5 7 "K,L,M,N - Banking and finance", modify label def Inde07m5 8 "O,P,Q - Public admin, education and health", modify label def Inde07m5 9 "R,S,T,U - Other services", modify label values FLEXW7 FLEXW75 label def FLEXW75 1 "Yes", modify label values FTPT FTPT5 label def FTPT5 1 "Full time", modify label def FTPT5 2 "Part time", modify label values SEX SEX label def SEX 1 "Male", modify label def SEX 2 "Female", modify
it contains the time variable "quarter" and also the week variable in which the week interview was conducted "WEEk" and also the industry sector in the main job variable "Inde07m "but this variable is a factor variable, and it contains all industry (for example manufacturing, accommodation … ..etc.) its range from 1 to 9, in other words, manufacturing industry takes the value "1", the accommodation industry takes the value "2" ... etc.
The external data is:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str24 A str68 B str19 C str33 D str52 E "date " "Industry" "Continuing to trade" "Has permanently ceased trading **" "Has temporarily closed or temporarily paused trading" "06/04/2020 to 19/04/2021" "Manufacturing" ".772" ".002" ".227" "06/04/2020 to 19/04/2021" "Water Supply, Sewerage, Waste Management And Remediation Activities" ".92" "0" ".08" "06/04/2020 to 19/04/2022" "Construction" ".709" "0" ".291" "06/04/2020 to 19/04/2023" "Wholesale And Retail Trade; Repair Of Motor Vehicles And Motorcycles" ".728" ".002" ".27" "06/04/2020 to 19/04/2024" "Accommodation And Food Service Activities" ".184" ".004" ".8120000000000001" "06/04/2020 to 19/04/2025" "Transportation And Storage" ".923" "0" ".077" "06/04/2020 to 19/04/2026" "Information And Communication" ".944" ".005" ".051" "06/04/2020 to 19/04/2027" "Professional, Scientific And Technical Activities" ".962" ".001" ".037" "06/04/2020 to 19/04/2028" "Administrative And Support Service Activities" ".897" ".007" ".096" "06/04/2020 to 19/04/2029" "Education" ".858" ".003" ".138" "06/04/2020 to 19/04/2030" "Human Health And Social Work Activities" ".956" ".009" ".035" "06/04/2020 to 19/04/2031" "Arts, Entertainment And Recreation" ".167" ".011" ".822" "06/04/2020 to 19/04/2032" "All Industries" ".754" ".003" ".243" "06/04/2020 to 19/04/2020" "Manufacturing" ".79" "*" ".206" "06/04/2020 to 19/04/2021" "Water Supply, Sewerage, Waste Management And Remediation Activities" ".9" "*" ".1" "06/04/2020 to 19/04/2022" "Construction" ".732" "*" ".261" "06/04/2020 to 19/04/2023" "Wholesale And Retail Trade; Repair Of Motor Vehicles And Motorcycles" ".752" "*" ".243" "06/04/2020 to 19/04/2024" "Accommodation And Food Service Activities" ".182" ".012" ".806" "06/04/2020 to 19/04/2025" "Transportation And Storage" ".915" "*" ".085" "06/04/2020 to 19/04/2026" "Information And Communication" ".95" "*" ".045" "06/04/2020 to 19/04/2027" "Professional, Scientific And Technical Activities" ".967" "*" ".03" "06/04/2020 to 19/04/2028" "Administrative And Support Service Activities" ".915" "*" ".081" "06/04/2020 to 19/04/2029" "Education" ".868" "*" ".126" "06/04/2020 to 19/04/2030" "Human Health And Social Work Activities" ".9379999999999999" ".014" ".049" "06/04/2020 to 19/04/2031" "Arts, Entertainment And Recreation" ".205" "*" ".795" "06/04/2020 to 19/04/2032" "All Industries" ".767" "*" ".228" "20/04/2020 - 03/05/2020" "Manufacturing" ".859" "*" ".139" "20/04/2020 - 03/05/2021" "Water Supply, Sewerage, Waste Management And Remediation Activities" ".971" "*" ".029" "20/04/2020 - 03/05/2022" "Construction" ".781" "*" ".216" "20/04/2020 - 03/05/2023" "Wholesale And Retail Trade; Repair Of Motor Vehicles And Motorcycles" ".799" "*" ".2" "20/04/2020 - 03/05/2024" "Transportation And Storage" ".95" "*" ".05" "20/04/2020 - 03/05/2025" "Accommodation And Food Service Activities" ".219" "*" ".781" "20/04/2020 - 03/05/2026" "Information And Communication" ".95" "*" ".045" "20/04/2020 - 03/05/2027" "Real Estate Activities" ".93" ".014" ".056" "20/04/2020 - 03/05/2028" "Professional, Scientific And Technical Activities" ".955" ".011" ".034" "20/04/2020 - 03/05/2029" "Administrative And Support Service Activities" ".927" "*" ".071" "20/04/2020 - 03/05/2030" "Education" ".892" ".01" ".098" "20/04/2020 - 03/05/2031" "Human Health And Social Work Activities" ".954" "*" ".038" "20/04/2020 - 03/05/2032" "Arts, Entertainment And Recreation" ".196" "*" ".801" "20/04/2020 - 03/05/2033" "All Industries" ".793" "*" ".203" "04/05/2020 - 17/05/2020" "Manufacturing" ".923" "*" ".074" "04/05/2020 - 17/05/2021" "Water Supply, Sewerage, Waste Management And Remediation Activities" ".955" "*" ".045" "04/05/2020 - 17/05/2022" "Construction" ".804" "*" ".191" "04/05/2020 - 17/05/2023" "Wholesale And Retail Trade; Repair Of Motor Vehicles And Motorcycles" ".85" "*" ".148" "04/05/2020 - 17/05/2024" "Transportation And Storage" ".945" "*" ".055" "04/05/2020 - 17/05/2025" "Accommodation And Food Service Activities" ".254" "*" ".741" "04/05/2020 - 17/05/2026" "Information And Communication" ".9379999999999999" "*" ".058" "04/05/2020 - 17/05/2027" "Real Estate Activities" ".957" ".014" ".029" "04/05/2020 - 17/05/2028" "Professional, Scientific And Technical Activities" ".971" "*" ".026" "04/05/2020 - 17/05/2029" "Administrative And Support Service Activities" ".911" "*" ".086" "04/05/2020 - 17/05/2030" "Education" ".903" "*" ".094" "04/05/2020 - 17/05/2031" "Human Health And Social Work Activities" ".959" "*" ".033" "04/05/2020 - 17/05/2032" "Arts, Entertainment And Recreation" ".25" "*" ".746" "04/05/2020 - 17/05/2033" "All Industries" ".82" "*" ".177" "17/05/2020 - 31/05/2020" "Manufacturing" ".951" "*" ".048" "17/05/2020 - 31/05/2021" "Water Supply, Sewerage, Waste Management And Remediation Activities" "1" "0" "0" "17/05/2020 - 31/05/2022" "Construction" ".826" "*" ".17" "17/05/2020 - 31/05/2023" "Wholesale And Retail Trade; Repair Of Motor Vehicles And Motorcycles" ".882" "*" ".115" "17/05/2020 - 31/05/2024" "Transportation And Storage" ".957" "*" ".04" "17/05/2020 - 31/05/2025" "Accommodation And Food Service Activities" ".344" "*" ".653" "17/05/2020 - 31/05/2026" "Information And Communication" ".945" "*" ".048" "17/05/2020 - 31/05/2027" "Real Estate Activities" ".9399999999999999" ".012" ".048" "17/05/2020 - 31/05/2028" "Professional, Scientific And Technical Activities" ".966" ".011" ".024" "17/05/2020 - 31/05/2029" "Administrative And Support Service Activities" ".91" "*" ".087" "17/05/2020 - 31/05/2030" "Education" ".893" "*" ".104" "17/05/2020 - 31/05/2031" "Human Health And Social Work Activities" ".947" "*" ".045" "17/05/2020 - 31/05/2032" "Arts, Entertainment And Recreation" ".299" "*" ".698" "17/05/2020 - 31/05/2033" "All Industries" ".841" "*" ".155" end
It has six waves of how Covid-19 affected the industry in the labour market (each wave constitutes two weeks) containing divisions of the variable "Inde07m" and coded as a percentage : continuing to trade , or permanently ceased trading ,or temporarily paused trading during the covid-19.
I want to combine this external data based on time and industry. In other words, I want to get a column in the data after the merge, saying that the manufacturing industry was temporarily paused trading from April 20 to May 3, and so forth.
I'm a new user of Stata. What is the best way to merge these two datasets? Could we solve this directly from the merge, and how can we do that? Or must you code the data differently before merging?
I appreciate any contribution to solving this problem.
Comment