+ Reply to Thread
Results 1 to 19 of 19

Pls Help, creating panel data by converting several columns into one

  1. #1
    Registered User
    Join Date
    06-20-2011
    Location
    Atlanta, GA, USA
    MS-Off Ver
    Excel 2007
    Posts
    2

    Pls Help, creating panel data by converting several columns into one

    Hi guys,

    First of all - great forum, have been following passively for some time and hoped to find help with this, no luck though.

    My problem:
    I have downloaded national economic data from IMF with several countries for several years. I need several variables and must extract them individually so I a need a clever solution to my problem.
    I currently have data that is sorted like below. The "-" indicates a numerical gdp value for the given country for the given year.;
    (FYI I could not get the "-" to align beneath 2001-2004 and year respectively.)


    Country 2001 2002 2003 2004
    x - - - -
    y - - - -
    z - - - -

    The identifier here is country, and the data is as such structered as cross sectional data, with each yearly account of gdp being a variable.
    Now, I need this data as panel data, organized as below;

    Country year gdp
    x 2001 -
    x 2002 -
    x 2003 -
    x 2004 -

    I sort of say, need to "flip it". As I have 180 countries and 11 years, and need to do this with 2-3 variables, I need either a formula or a VBA to run.

    Can anyone help me here?

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,379

    Re: Pls Help, creating panel data by converting several columns into one

    Hi kaspernrasmussen and welcome to the forum,

    Find the attached with a macro in it called Flip()..

    I think this will do what you want.
    Attached Files Attached Files
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Forum Guru
    Join Date
    05-24-2011
    Location
    India
    MS-Off Ver
    365
    Posts
    2,243

    Re: Pls Help, creating panel data by converting several columns into one

    Hello, kaspernrasmussen;

    Also try this with Formulas. See the attached.
    Regards,
    Haseeb Avarakkan

    __________________________________
    "Feedback is the breakfast of champions"

  4. #4
    Registered User
    Join Date
    06-20-2011
    Location
    Atlanta, GA, USA
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Pls Help, creating panel data by converting several columns into one

    This is really great - just took a look at the formula - looks exactly as what I need to. Perfect.
    Its amazing what excel can do - you just need to ask the right persons.
    Thanks again.

  5. #5
    Registered User
    Join Date
    08-02-2011
    Location
    new york, usa
    MS-Off Ver
    Excel 2003
    Posts
    1

    Re: Pls Help, creating panel data by converting several columns into one

    Brilliant - exactly what i needed thank you guys

  6. #6
    Registered User
    Join Date
    02-16-2012
    Location
    Norway
    MS-Off Ver
    Excel 2011 mac
    Posts
    3

    Re: Pls Help, creating panel data by converting several columns into one

    Great tip, but how do you get the formulas working for more variables? I have 10 variables for 5 years.

  7. #7
    Registered User
    Join Date
    02-16-2012
    Location
    Norway
    MS-Off Ver
    Excel 2011 mac
    Posts
    3

    Re: Pls Help, creating panel data by converting several columns into one

    Like this:

    Company Year Non current liabilitie Current liabilities Total asset Tangible fixed assets x....
    LACO AS 2010
    LACO AS 2009
    LACO AS 2008
    LACO AS 2007
    LACO AS 2005
    AWILHELMSEN AS 2010
    AWILHELMSEN AS 2009
    AWILHELMSEN AS 2008
    AWILHELMSEN AS 2007
    AWILHELMSEN AS 2005
    AWILHELMSEN HOLDING AS 2010
    AWILHELMSEN HOLDING AS 2009
    AWILHELMSEN HOLDING AS 2008

  8. #8
    Registered User
    Join Date
    07-06-2012
    Location
    Denmark
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Pls Help, creating panel data by converting several columns into one

    Hi,

    New to the forum - thanks a lot to all the experts, it is a great help. Just as Pettering above I would like to know if there is a way to include more variables?

    Cheers,
    Stu

  9. #9
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: Pls Help, creating panel data by converting several columns into one

    Stu,

    Welcome to the Forum, unfortunately:

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread. It makes sense to have a new thread for your question because a thread with numerous replies can be off putting & difficult to pick out relevant replies.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  10. #10
    Registered User
    Join Date
    05-14-2013
    Location
    amsterdam
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Pls Help, creating panel data by converting several columns into one

    You just saved me 10 days of work! Thank you so much MarvinP!!

  11. #11
    Registered User
    Join Date
    08-07-2013
    Location
    Brussels
    MS-Off Ver
    Excel 2003
    Posts
    1

    Re: Pls Help, creating panel data by converting several columns into one

    Quote Originally Posted by Haseeb A View Post
    Hello, kaspernrasmussen;

    Also try this with Formulas. See the attached.
    Thanks for this excellent, user friendly solution.

  12. #12
    Registered User
    Join Date
    11-29-2013
    Location
    Los Angeles
    MS-Off Ver
    Excel 2010
    Posts
    1

    Re: Pls Help, creating panel data by converting several columns into one

    Thank you so much for the great solutions posted. They are very useful..

  13. #13
    Registered User
    Join Date
    07-22-2014
    Location
    Seattle, WA
    MS-Off Ver
    2013
    Posts
    1

    Re: Pls Help, creating panel data by converting several columns into one

    Thank you Marvin. That saved up a lot of time.

  14. #14
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,379

    Re: Pls Help, creating panel data by converting several columns into one

    Hi meronmas and welcome to the forum,

    After writing "Flip" a few years ago, this type of problem kept appearing in the forum. I improved the macro so it could deal with Crosstab tables of different sizes and fixed columns. Find attached a newer version of the macro in the attached.
    Attached Files Attached Files

  15. #15
    Registered User
    Join Date
    06-06-2015
    Location
    Australia
    MS-Off Ver
    MS Office 7
    Posts
    1

    Re: Pls Help, creating panel data by converting several columns into one

    That is perhaps the most amazing and helpful macro ever.


    Thankful econometrics student.

  16. #16
    Registered User
    Join Date
    05-25-2017
    Location
    Gurgaon
    MS-Off Ver
    2010
    Posts
    6

    Re: Pls Help, creating panel data by converting several columns into one

    Thank you so much MarvinP for the macro that you have created to create panel data. It is a great help, good day.

  17. #17
    Registered User
    Join Date
    05-25-2017
    Location
    Gurgaon
    MS-Off Ver
    2010
    Posts
    6

    Re: Pls Help, creating panel data by converting several columns into one

    HI
    Have u got this query solved, i also have same kind of data.

  18. #18
    Registered User
    Join Date
    05-25-2017
    Location
    Gurgaon
    MS-Off Ver
    2010
    Posts
    6

    Re: Pls Help, creating panel data by converting several columns into one

    hi

    have u got your query solved, how to do this as i also have same kind of data.

  19. #19
    Registered User
    Join Date
    07-11-2017
    Location
    Rotterdam
    MS-Off Ver
    Excel 2013
    Posts
    1

    Red face Re: Pls Help, creating panel data by converting several columns into one

    Thank you Haseeb, you literally saved the day!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1