+ Reply to Thread
Results 1 to 2 of 2

Observation of areas whose population mixes - panel data set

  1. #1
    Registered User
    Join Date
    04-29-2019
    Location
    Tel Aviv, Israel
    MS-Off Ver
    2013
    Posts
    13

    Observation of areas whose population mixes - panel data set

    Hey everybody,

    I have an issue in my work and I'm trying to solve it with multiple nested loops, but it becomes very complicated and yet I'm not 100% sure it does the job. I was wondering if there might be a simple solution for this.

    I'll try to keep it short but comprehensible (the next section just gives some context, you may skip it):

    In my data, an observation represents a geographic area ("statistical area") with defined boundaries in a specific year, and contains some demographic information about the population living in that area. The problem is that at some point of time, extensive changes have been made in regards to the boundaries of these areas, as well as to the numbers identifying them. An area might has been split, a few areas might have been united and, worst of all, some areas might have been split and united with others.
    Bottom line, the meaning of all this is that looking at a statistical area level data isn't relevant, as the observations don't represent the same population. Area number 8 in 1999 doesn't represent the same population as area number 8 in 2009.

    Here is what I need:

    I have a list (part of which is attached as an example) of all the changes that have been made. The list goes as follows: the first number is the area's number before 2008, the second number is the area's number post-2008 and the third number is the change type (change 4 is the problematic type that combines split and unification of a few areas). This means that areas appear more than once on the list - for example, an area that was split appears twice with the same old number, and in the second column it has two different numbers which are the numbers of the two new areas it was split to.

    What I need my code to do is to create a new column in which a number will be assigned to each line, and Lines with the same numbers in either of the "area" column (area_95 or area_08) should recieve the same number in the new column. Note the highlighted lines for example: the code should assign lines 4,5 the same number due to both of their "area_95" being 2. But then, it should assign the same number to line 9, because of its "area_08" being 7. And then, it should assign that number to line 10 as well, because its "area_95" is also 6.
    (obviously the list of changes is very long and I have no way of tracking all the lines, so as I said I need something that will work for sure rather than a very long chain of nested loop with which I can only hope it's long enough to group all the areas with mixed population together).

    Thanks in advance,
    Ben
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,535

    Re: Observation of areas whose population mixes - panel data set

    It is a good idea to supply the forum with manually placed results so that the contributors may use them to compare the results they get from their formulas/code.
    That said, and assuming that I understand the request correctly, here is a two column (E:F), formula based proposal, with the final arrangement being in column F.
    Cell E2 is populated with the number 1
    Cells E3:E20 is populated using: =IFNA(INDEX(B$2:B2,MATCH(C3,C$2:C2,0)),B3)
    Cell F2 is again populated with the number 1
    Cell F3:F20 is populated using: =IFNA(INDEX(E$2:E2,MATCH(B3,B$2:B2,0)),E3)

    Late addition: I noticed that C12 and C15 both contain the value of 3. I am guessing that in the final arrangement row 15 should have a value of 7.
    IF that is the case then add the following in G2:G20 =IF(OR(E2=B2,F2=E2),F2,E2)

    Let us know if you have any questions.
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

+ 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. Count only distinct observation based in ID - data in long format
    By Marvin85 in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 01-27-2016, 11:51 AM
  2. Monthly observation as observation per weekday?
    By Lv27 in forum Excel General
    Replies: 1
    Last Post: 04-10-2013, 02:49 PM
  3. [SOLVED] How to sort Numbers & Text in one column -- Pivot mixes them up
    By markDuffy in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 02-16-2013, 11:09 AM
  4. How to sort Numbers & Text in one column -- Pivot mixes them up
    By markDuffy in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 02-14-2013, 03:36 PM
  5. [SOLVED] Count rows between two areas in a collection/selection of multiple areas
    By JTwrk in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-02-2012, 10:38 AM
  6. Replies: 0
    Last Post: 07-10-2012, 08:37 AM
  7. Replies: 5
    Last Post: 10-13-2010, 04:47 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