From wide to long format

Hello everyone,

I am here to ask for help. I have currently managed to gathered quite some data together for the first time in my life (for my Thesis). I am encountering issues in transforming the data from wide to long format.
As of now I have 16806 companies (rows) and 490 variables (columns). The problem is that the variables are actually 17 but are repeated for each column as I am analysing them over a long time period (17 years - 2003:2020). So, for example I have:

  • company ID - Location -Industry -ROA2003 - ROA2004 ROA2005 -ROA2006 ...and so on.
    I have been trying to research and apply all possible things to transform this data set in a long format but I have not managed to do so yet.
    I would really appreciate some help.

Thanks a lot in advance.


Heya! this link would help you :slight_smile:

This should be quite easy using the stack command - the following example uses the built-in iris dataset:


Hope this helps!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.