I have a large data set with information about 166 bonds, their characteristics, followed by daily yield data over a five year period (although most of these values are missing). The data is formatted as a wide format panel but it seems as if I need to reshape the data into a long format to use in Stata.
The data looks as follows:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str13 RIC str59 IssuerName str6 IssuerTicker str8 Rating str6 Coupon byte date31122013 double date31122018 "NL180873945=" "ABN AMRO BANK NV" "ABNAM" "P-1" "SR" . .05308791208791219 "ES164276376=" "ADIF ALTA VELOCIDAD" "MNDEFA" "WD" "SR" . -.010077997671711247 "00828EDF3=" "AFRICAN DEVELOPMENT BANK" "AFDB" "Aaa" "SR" . -.02932627737226312 "015271AM1=" "ALEXANDRIA REAL ESTATE EQUITIES INC" "ARE" "BBB+" "SR" . -.07321824817518285 "037833BU3=" "APPLE INC" "AAPL" "P-1" "SR" . .03468363636363625 "037833CX6=" "APPLE INC" "AAPL" "P-1" "SR" . .007064516129032139 "045167DQ3=" "ASIAN DEVELOPMENT BANK" "ADB" "AAA" "SR" . -.009346153846153893 "XS179621193=" "ASIAN DEVELOPMENT BANK" "ADB" "AAA" "SR" . -.00039999999999995595 "XS181439009=" "ASIAN DEVELOPMENT BANK" "ADB" "AAA" "SR" . .0004339622641509333 "XS161817856=" "ASIAN DEVELOPMENT BANK" "ADB" "AAA" "SR" . . "045167EB5=" "ASIAN DEVELOPMENT BANK" "ADB" "AAA" "SR" . -.023430869971936552 "045167CY7=" "ASIAN DEVELOPMENT BANK" "ADB" "AAA" "SR" . .026511597374179185 "045167DR1=" "ASIAN DEVELOPMENT BANK" "ADB" "AAA" "SR" . .01513764258555117 "045167EC3=" "ASIAN DEVELOPMENT BANK" "ADB" "AAA" "SR" . .015742857142857503 "SE0009779465=" "ATRIUM LJUNGBERG AB" "ATRLJ" "Baa2" "SR" . . "05463CAD4=" "AXIS BANK LTD (DUBAI BRANCH)" "AXBKD" "Baa2(cr)" "SR" . -.0135021013597032 "IN141034138=" "AXIS BANK LTD (DUBAI BRANCH)" "AXBKD" "Baa2(cr)" "SR" . -.013702101359703178 "06051GGB9=" "BANK OF AMERICA CORP" "BAC" "Baa1" "SR" . -.09311153846153886 "06051GHH5=" "BANK OF AMERICA CORP" "BAC" "Baa1" "SR" . -.17016629834254138 "DEBHY0GP=" "BERLIN HYP AG" "EWRSFY" "Aaa" "MTG" . .02428253968253965 "DEBHY0GH=" "BERLIN HYP AG" "EWRSFY" "Aaa" "MTG" . -.010500000000000037 "DEBHY0GC=" "BERLIN HYP AG" "EWRSFY" "Aaa" "MTG" . .011591891891891859 "FR180833854=" "BNP PARIBAS SA" "BNP" "P-1" "SRBN" . .24590909090909108 "FR0013067170=" "BPCE SA" "BPCSA" "A" "SR" . -.032315068493150745 "IT188639356=" "CASSA DEPOSITI E PRESTITI SPA" "CSDPR" "WD" "SR" . .06592613636363609 "SE0009161615=" "CASTELLUM AB" "CASTZ" "(P)Baa3" "SR" . . "CN171117321=" "CHINA DEVELOPMENT BANK" "CNDBK" "AAA" "SR" . -.17748837209302326 "CN171103959=" "CHINA DEVELOPMENT BANK" "CNDBK" "AAA" "SR" . .06773565217391342 "AUCBA0322=" "COMMONWEALTH BANK OF AUSTRALIA" "CBA" "P-1" "SR" . .18568518518518484 "NL150243882=" "COOPERATIEVE RABOBANK UA" "RABO" "AA-" "SR" . -.06003296703296705 "FR114083402=" "CREDIT AGRICOLE CORPORATE AND INVESTMENT BANK SA" "CAGRAB" "BBB+" "SR" . .1629516616314195 "FR114083330=" "CREDIT AGRICOLE CORPORATE AND INVESTMENT BANK SA" "CAGRAB" "BBB+" "SR" . -.2205882352941182 "FR136722948=" "CREDIT AGRICOLE CORPORATE AND INVESTMENT BANK SA" "CAGRAB" "BBB+" "SR" . -.03142187499999993 "JP150565553=" "DEVELOPMENT BANK OF JAPAN INC" "DBJPN" "AAA" "SR" . -.044623430962343225 "JP169765146=" "DEVELOPMENT BANK OF JAPAN INC" "DBJPN" "AAA" "SR" . -.04254054054054057 "25389JAL0=" "DIGITAL REALTY TRUST LP" "DLRLT" "Baa2" "SR" . -.01493203539823007 "PT189362102=" "EDP FINANCE BV" "EDPPF" "A-3" "SR" . -.04293548387096813 "NO1080686=" "EIDSIVA ENERGI AS" "EIDEN" "NULL" "SR" . . "IT155014920=" "ENEL FINANCE INTERNATIONAL NV" "ENEIL" "A-" "SR" . -.12439784946236565 "FR0011911239=" "ENGIE SA" "ENGIE" "BBB+" "SR" . . "29874QCW2=" "EUROPEAN BANK FOR RECONSTRUCTION AND DEVELOPMENT" "EBRD" "Aaa" "SR" . .08930545454545458 "29874QDG6=" "EUROPEAN BANK FOR RECONSTRUCTION AND DEVELOPMENT" "EBRD" "Aaa" "SR" . .0916947368421055 "29878TCS1=" "EUROPEAN INVESTMENT BANK" "EIB" "Aaa" "SR" . .020111363636363677 "XS131433620=" "EUROPEAN INVESTMENT BANK" "EIB" "Aaa" "SR" . .020511363636363633 "XS134620218=" "EUROPEAN INVESTMENT BANK" "EIB" "Aaa" "SR" . -.14971345595353336 "XS155129301=" "EUROPEAN INVESTMENT BANK" "EIB" "Aaa" "SR" . -.00035237173281710277 "XS128083499=" "EUROPEAN INVESTMENT BANK" "EIB" "Aaa" "SR" . -.0305 "XS175742808=" "EUROPEAN INVESTMENT BANK" "EIB" "Aaa" "SR" . .0031534246575343206 "XS181185210=" "EUROPEAN INVESTMENT BANK" "EIB" "Aaa" "SR" . 0 "XS187883369=" "EUROPEAN INVESTMENT BANK" "EIB" "Aaa" "SR" . -.08431147540983608 "XS110771827=" "EUROPEAN INVESTMENT BANK" "EIB" "Aaa" "SR" . -.038680327868852504 "30216BGU0=" "EXPORT DEVELOPMENT CANADA" "EDC" "AAA" "SR" . .07675723270440216 "IN120986422=" "EXPORT IMPORT BANK OF INDIA" "EXIMB" "BBB+" "SR" . .3240222222222222 "302154BZ1=" "EXPORT-IMPORT BANK OF KOREA" "KEXIM" "AA-" "SR" . .10031914893617033 "KR165532295=" "EXPORT-IMPORT BANK OF KOREA" "KEXIM" "AA-" "SR" . .16859999999999964 "KR179009986=" "EXPORT-IMPORT BANK OF KOREA" "KEXIM" "AA-" "SR" . .13540188679245269 "IT173240031=" "FERROVIE DELLO STATO ITALIANE SPA" "FRSTO" "WD" "SR" . .5752306976744184 "CH38787903=" "GENEVA, CANTON OF" "GNEVA" "AA-" "SR" . . "CH38787904=" "GENEVA, CANTON OF" "GNEVA" "AA-" "SR" . . "373334KE0=" "GEORGIA POWER CO" "SOGEP" "VMIG 2" "SR" . .01705000000000023 "SE125384781=" "GOTHENBURG, MUNICIPALITY OF" "GTBRG" "P-1" "SR" . .02550000000000001 "SE143308286=" "GOTHENBURG, MUNICIPALITY OF" "GTBRG" "P-1" "SR" . -.0036985645933014233 "SE162777831=" "GOTHENBURG, MUNICIPALITY OF" "GTBRG" "P-1" "SR" . .02189999999999992 "HK171984696=" "HKCG FINANCE LTD" "HKCNGF" "A+" "SR" . -.01507903780068709 "KR137942992=" "HYUNDAI CAPITAL SERVICES INC" "HYMTRD" "BBB+" "SR" . .42423520309477736 "44920UAG3=" "HYUNDAI CAPITAL SERVICES INC" "HYMTRD" "BBB+" "SR" . .41953520309477765 "ES105705506=" "IBERDROLA INTERNATIONAL BV" "IBERD" "P-2" "SR" . -.08899999999999997 "FR0013281755=" "ICADE SA" "ICAD" "BBB+" "SR" . -.12478980891719749 "CN183098527=" "INDUSTRIAL AND COMMERCIAL BANK OF CHINA LTD (LONDON BRANCH)" "ICBATF" "P-1" "SR" . .09388888888888891 "NL132421773=" "ING BANK NV" "INGBK" "F1+" "SR" . .06471480144404333 "DE170272927=" "INNOGY FINANCE BV" "IGYIG" "BBB" "SR" . -.053559585492227946 "XS151726810=" "INTERNATIONAL BANK FOR RECONSTRUCTION AND DEVELOPMENT" "IBRD" "Aaa" "SR" . 1.2643842105263159 "45905UX33=" "INTERNATIONAL BANK FOR RECONSTRUCTION AND DEVELOPMENT" "IBRD" "Aaa" "SR" . .3536029411764696 "XS185633802=" "INTERNATIONAL BANK FOR RECONSTRUCTION AND DEVELOPMENT" "IBRD" "Aaa" "SR" . .052601351351351355 "45905URL0=" "INTERNATIONAL BANK FOR RECONSTRUCTION AND DEVELOPMENT" "IBRD" "Aaa" "SR" . .015238888888888802 "45905U6L3=" "INTERNATIONAL BANK FOR RECONSTRUCTION AND DEVELOPMENT" "IBRD" "Aaa" "SR" . -.41844842105263114 "AUIBR1125=" "INTERNATIONAL BANK FOR RECONSTRUCTION AND DEVELOPMENT" "IBRD" "Aaa" "SR" . .0029792531120329535 "SE0009921950=" "VOLVOFINANS BANK AB" "VOLBK" "P-1" "SR" . . "95709TAN0=" "WESTAR ENERGY INC" "EVRGW" "NR" "1STMTG" . -.0958436213991769 "SE0009357338=" "VASTERAS, MUNICIPALITY OF" "VAEST" "AAA" "SR" . . "SE0009190606=" "VASAKRONAN AB (PUBL)" "VASKNV" "A3" "SR" . . "SE0011425834=" "VASAKRONAN AB (PUBL)" "VASKNV" "A3" "SR" . . "SE0010832949=" "VASAKRONAN AB (PUBL)" "VASKNV" "A3" "SR" . . "SE0011062967=" "VASAKRONAN AB (PUBL)" "VASKNV" "A3" "SR" . . "SE0010948661=" "VASAKRONAN AB (PUBL)" "VASKNV" "A3" "SR" . . "SE0011062298=" "VASAKRONAN AB (PUBL)" "VASKNV" "A3" "SR" . . "SE0007666136=" "VASAKRONAN AB (PUBL)" "VASKNV" "A3" "SR" . . "SE0007666128=" "VASAKRONAN AB (PUBL)" "VASKNV" "A3" "SR" . . "SE0010297424=" "VASAKRONAN AB (PUBL)" "VASKNV" "A3" "SR" . . "SE0010832899=" "VASAKRONAN AB (PUBL)" "VASKNV" "A3" "SR" . . "SE0010442699=" "VASAKRONAN AB (PUBL)" "VASKNV" "A3" "UN" . . "SE0006452553=" "VASAKRONAN AB (PUBL)" "VASKNV" "A3" "SR" . . "SE0009607013=" "VASAKRONAN AB (PUBL)" "VASKNV" "A3" "SR" . . "FR121831970=" "UNIBAIL RODAMCO SE" "UNBLR" "A" "SR" . -.007110236220472466 "FR103870852=" "UNIBAIL RODAMCO SE" "UNBLR" "A" "SR" . .01753387096774206 "JP172063977=" "TOYOTA MOTOR CREDIT CORP" "TOYOMF" "Aa3" "SR" . -.04237297297297292 "89114QBT4=" "TORONTO-DOMINION BANK" "TD" "Aa3" "SR" . -.0702387755102043 "NL124158109=" "TENNET HOLDING BV" "TNETH" "NR" "SR" . -.0611532884515793 "NL143238466=" "TENNET HOLDING BV" "TNETH" "NR" "SR" . .03902226825479027 "NL163289776=" "TENNET HOLDING BV" "TNETH" "NR" "SR" . -.03450077679958563 end
The outcome I'm trying to achieve is to have the RIC code, the yield, and the 12 variables as columns with the daily yield (i.e. the observation) in rows, and then the value for each variable on each row (which is the same for every date as it simply is a characteristic of the bond itself, so it doesn't vary every day). This would generate a panel with a very large number of rows, but if I understand correctly this shouldn't be a problem. How do I best go about doing this? I've tried using reshape but wasn't successful in doing so.
Many thanks,
Nils
0 Response to Reshape large panel data set with multiple variables and daily data
Post a Comment