Stacking one column while duplicating other column in Excel or Stata -


i working on huge dataset in excel file. data has daily stock returns of 380 companies 2016 2000. each company has 3800 observations. first column has dates in excel format in descending order. successive columns have returns of companies correspond dates.

i have import dataset stata panel data analysis , unfortunately above arrangement not in that. have rearrange data either in stata or in excel , can't seem automatically.

rearrangement:

  1. i looking sort data 3 columns only. first column have company names stacked below each other.
  2. the second column has dates duplicate whenever new company starts.
  3. the third column should have returns of companies stacked below each other.

illustration

it converting data long form in stata. not sure if excel able handle since each company have 3800 rows , there 380 companies.

in excel, developed macro stack columns of returns not not make dates column , company names move along it.
in stata, tired reshape command gives mismatch error. stack command let me stack returns drops other information. new stata don't know how approach problem through developing loop.

you don't give indication of code tried in stata: see https://stackoverflow.com/help/mcve advice on makes question.

on face of problem soluble in stata

reshape long company, i(date)  rename (company _j) (return company)  

Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -