Hello
I have unfortunately (again) an problem to reshape a data file that is present in quite a weird format (see example):
1. line: empty (can be deleted)
2. line: Variable Name (Single for constant values like Names etc. ; repeated for time changing values like Sales)
3. line: Variable ID (can be deleted)
4. line: Time Variable (only for variables that change over time otherwise empty)
My concrete Problem is that I have two lines in which date and variable names are stored separately (YearQuarter format).
I want to reshape the data in long format to have a Panel Dataset in the end.
I extracted an example from Stata here. I had to censor the data that is why there is always written RN , the variable might be string or numeric though. Also the variables are named from A to MF. I included some variables to illustrate the problem with the time Variable that is in the 4th row only for some Variables.
Edit: Since I recognized the wording above might be misleading here a more precise example:
(extracted by using dataex: https://ideas.repec.org/c/boc/bocode...ml#biblio-body)
Thank you for any suggestions or tips how to circumvent manually reshaping this in excel.
Best
Justus
I have unfortunately (again) an problem to reshape a data file that is present in quite a weird format (see example):
1. line: empty (can be deleted)
2. line: Variable Name (Single for constant values like Names etc. ; repeated for time changing values like Sales)
3. line: Variable ID (can be deleted)
4. line: Time Variable (only for variables that change over time otherwise empty)
My concrete Problem is that I have two lines in which date and variable names are stored separately (YearQuarter format).
I want to reshape the data in long format to have a Panel Dataset in the end.
I extracted an example from Stata here. I had to censor the data that is why there is always written RN , the variable might be string or numeric though. Also the variables are named from A to MF. I included some variables to illustrate the problem with the time Variable that is in the 4th row only for some Variables.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str17 A str16 B str13 C str26 D str21 E str17 F str20 G str25(EG EH EI) "Source" "" "" "" "" "" "" "" "" "" "Institution Name " "Institution Key " "Ticker " "Trading Symbol & Exchange " "S&P CapIQ Company ID " "Ownership Status " "Company Name, Short " "Total Deposits (Reported)" "Total Deposits (Reported)" "Total Deposits (Reported)" "130509" "130992" "131166" "139474" "263978" "255389" "131160" "132288" "132288" "132288" "" "" "" "" "" "" "" "2008Q4" "2008Q3" "2008Q2" "" "" "" "" "" "" "" "Current/Restated" "Current/Restated" "Current/Restated" "Company1" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "Company2" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "Company3" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "Company4" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "Company5" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "Company6" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "Company7" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "Company8" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "Company9" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "Company10" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" "RANDOM NUMBER" end
Edit: Since I recognized the wording above might be misleading here a more precise example:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str17 A str16 B str10 C str26 D str21 E str23(AO AP AQ AR AS) "Source" "" "" "" "" "" "" "" "" "" "Institution Name " "Institution Key " "Ticker " "Trading Symbol & Exchange " "S&P CapIQ Company ID " "Total Assets (Reported)" "Total Assets (Reported)" "Total Assets (Reported)" "Total Assets (Reported)" "Total Assets (Reported)" "130509" "130992" "131166" "139474" "263978" "132264" "132264" "132264" "132264" "132264" "" "" "" "" "" "2012Q4" "2012Q3" "2012Q2" "2012Q1" "2011Q4" "" "" "" "" "" "Current/Restated" "Current/Restated" "Current/Restated" "Current/Restated" "Current/Restated" "Company1" "Identifier" "Identifier" "Identifier" "Identifier" "1" "1" "1" "1" "1" "Company2" "Identifier" "Identifier" "Identifier" "Identifier" "1" "1" "1" "1" "1" "Company3" "Identifier" "Identifier" "Identifier" "Identifier" "1" "1" "1" "1" "1" "Company4" "Identifier" "Identifier" "Identifier" "Identifier" "1" "1" "1" "1" "1" "Company5" "Identifier" "Identifier" "Identifier" "Identifier" "1" "1" "1" "1" "1" "Company6" "Identifier" "Identifier" "Identifier" "Identifier" "1" "1" "1" "1" "1" "Company7" "Identifier" "Identifier" "Identifier" "Identifier" "1" "1" "1" "1" "1" "Company8" "Identifier" "Identifier" "Identifier" "Identifier" "1" "1" "1" "1" "1" "Company9" "Identifier" "Identifier" "Identifier" "Identifier" "1" "1" "1" "1" "1" "Company10" "Identifier" "Identifier" "Identifier" "Identifier" "1" "1" "1" "1" "1" end
(extracted by using dataex: https://ideas.repec.org/c/boc/bocode...ml#biblio-body)
Thank you for any suggestions or tips how to circumvent manually reshaping this in excel.
Best
Justus
Comment