+ Reply to Thread
Results 1 to 4 of 4

Panel data calculation in single column.

Hybrid View

  1. #1
    Registered User
    Join Date
    05-12-2017
    Location
    london
    MS-Off Ver
    2007
    Posts
    2

    Panel data calculation in single column.

    Dear all,

    my panel data set consists of 28 countries for which I have one variable on an annual base for 18 years (1998 until 2015). The data set is strongly balanced though there are some data gaps. Column A consists of all countries, column B of the years and column C the data for the variable.

    For each given year I would like to calculate the difference in the variable for all country-pairs. For example:


    Name: Unbenannt.png
    Views: 15
    Size: 17.3 KB


    In this example I am interested in the difference in the GDP between Germany – UK, Germany-Belgium and UK-Belgium in the year 1998. In addition, I would like to calculate the differences for those three country-pairs for the years 1999 and 2000. However, I do not want to calculate differences across different years.

    Can you help me please to compute those differences? I also have to make sure that Excel computes only differences if data is available for both countries instead of filling gaps with a value of zero.

    Thank you very much.

    Kind regards
    Attached Images Attached Images
    Last edited by FDibbins; 05-14-2017 at 01:29 AM.

  2. #2
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Loop

    How about this. In B1 of sheet2 is a dropdown menu of the year (1998 to 2015)

    In Col A is unique list of countries (A4:A...), In Row 3 is Unique list of countries (copy column A and transpose it)

    So in B4 copied down and right

    =IF(B$3=$A4,"-",SUMIFS(Data!$C$2:$C$10,Data!$B$2:$B$10,$B$1,Data!$A$2:$A$10,$A4)-SUMIFS(Data!$C$2:$C$10,Data!$B$2:$B$10,$B$1,Data!$A$2:$A$10,B$3))
    Does that work for you?
    Attached Files Attached Files
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Registered User
    Join Date
    05-12-2017
    Location
    london
    MS-Off Ver
    2007
    Posts
    2

    Re: Loop

    Hello,

    thanks a lot for your reply. It makes already a very good impression.

    I'm sorry I was not precise enough. I need the results to be in one single column instead of a matrix. Could you still help me with that please?

    In addition, I would like to write down in the bordering cell the name of the respective country pair for which I make the current calculation.

    I used your file to give an example of how I imagined the result.

    Book3.xlsx

  4. #4
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,044

    Re: Loop

    Please take a moment to read the forum rules and then amend your thread title to something descriptive of your problem - not what you think the answer might be. (think google search terms?). Once you have done this please send me a PM and I will remove this request. (Also, include a link to your thread - copy from the address bar)

    Many members search our previous posts, and thread titles play a big part of the search. I doubt anybody would do a search based on your title?

    To change a Title on your post, click EDIT POST then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.

    (note: this change is not optional )
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] (Beginner help) For loop inside do loop that displays information from reference sheet.
    By lediable007 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 06-08-2016, 03:20 PM
  2. [SOLVED] Auto email loop with formatted table data breaking on second loop VBA
    By Who_else in forum Excel General
    Replies: 6
    Last Post: 03-24-2016, 06:22 AM
  3. [SOLVED] VBA to loop within a loop of multiple blocks of data (currentregion) ... Expert needed
    By Jim885 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-20-2016, 08:28 PM
  4. HOW TO: Pause loop, fix error on a popup UserForm, continue loop
    By AndyMachin in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 06-19-2014, 04:37 PM
  5. Loop through multiple files and call macros (but unable to loop)
    By ryanpetersen in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-23-2014, 12:04 PM
  6. [SOLVED] Copy dynamically changing column and Paste using VBA Loop (Loop within Loop)
    By nixon72 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-12-2013, 12:46 PM
  7. Why did an inner loop variable start overwriting the outer loop range suddenly?
    By 111StepsAhead in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-16-2012, 03:24 PM

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