Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Creating a time series that displays the minimum price for multiple offers of the same item that run for discrete time periods

    Hello

    I am currently working on a project which observes an identical product that being offered by multiple sellers for discrete periods of time. I am interested in understanding how the cheapest price of the product has changed with time. To give a bit more understanding, I have included a table below which illustrates what our dataset looks like:
    Seller ID Startdate Enddate Price
    A 1jun2017 2jan2018 100
    A 1jan2018 20may2018 110
    B 5apr2017 18jul2018 130
    ...

    Basically the desired output for this project would include the cheapest price provided by each seller for every date between 1 Jan 2016 and 31 May 2019. I have tried to show what this might look like below:
    Date A B
    2jan2018 100 130
    3jan2018 110 130
    ...

    The closest I have managed to get to this output is through a loop - however, my knowledge of looping is somewhat limited and I haven't been able to get the data into my desired format. The code I used is as follows:

    Code:
    forvalues i = 20454(1)21700 {
    table seller if startdate<`i' & enddate>`i', c(min price)
    }
    As you can probably see, the output here is multiple tables and is not particularly usable for my research.

    I would really appreciate any help that anyone can provide me!

    Thanks
    Last edited by Beau Jackson; 02 Jun 2019, 20:28.

  • #2
    I managed to work this one out. For anyone who is experiencing similar problems:

    Code:
    gen enddate2 = enddate - 20453
    gen startdate2 = startdate - 20453
    
    encode sellerid, gen(ensellerid)
    
    set matsize 11000
    
    matrix t1 = J(1247,5,.)
    forvalues i = 1(1)1247 {
    forvalues j = 1(1)2 {
    summarize price if enddate2>=`i' & startdate2<=`i' & ensellerid==`j'
    matrix t1[`i',`j'] = r(min)
    }
    }

    Comment

    Working...
    X