Hello, I believe there is a similar post out there related to first-difference of variable in panel data. I have a similar inquire with some slight differences, I am hoping to get some help with this.
I am looking to track which vehicles are entering and leaving my dataset from year to year within the same zip code (ZCTA). Basically, this is the question I am trying to answer. Within this zip code at year 2015 there are 10 specific vehicles (let's say they are a 2012 Tesla Model S), the next year (2016) that same zip code now has 15 vehicles (2012 Tesla Model S). From 2015 to 2016 there was a gain of 5 vehicles. The idea is this will go up and down for specific vehicles over different zip codes throughout time. As you can see from the dataset, in 2015 there is 2 2012 Nissan Leaf's and then again 2 in 2016 and then -1 in 2017 and so on. I am looking to generate a variable that captures this in a way that is generic for all zip codes in the dataset. Below is an example of my dataset. Thank you in advance for your help and suggestions.
dataex datayear zcta CT_Vehicle_ID total in 1/30
----------------------- copy starting from the next line -----------------------
------------------ copy up to and including the previous line ------------------
Listed 30 out of 40 observations
Thank you,
Adam
I am looking to track which vehicles are entering and leaving my dataset from year to year within the same zip code (ZCTA). Basically, this is the question I am trying to answer. Within this zip code at year 2015 there are 10 specific vehicles (let's say they are a 2012 Tesla Model S), the next year (2016) that same zip code now has 15 vehicles (2012 Tesla Model S). From 2015 to 2016 there was a gain of 5 vehicles. The idea is this will go up and down for specific vehicles over different zip codes throughout time. As you can see from the dataset, in 2015 there is 2 2012 Nissan Leaf's and then again 2 in 2016 and then -1 in 2017 and so on. I am looking to generate a variable that captures this in a way that is generic for all zip codes in the dataset. Below is an example of my dataset. Thank you in advance for your help and suggestions.
dataex datayear zcta CT_Vehicle_ID total in 1/30
----------------------- copy starting from the next line -----------------------
Code:
* Example generated by -dataex-. For more info, type help dataex clear input int(datayear zcta) str53 CT_Vehicle_ID double total 2015 6029 "nissan,leaf,2012" 2 2015 6029 "nissan,leaf,2015" 1 2015 6029 "tesla,model s,2014" 1 2016 6029 "nissan,leaf,2015" 2 2016 6029 "tesla,model s,2015" 1 2016 6029 "nissan,leaf,2012" 2 2016 6029 "tesla,model s,2014" 1 2017 6029 "nissan,leaf,2013" 1 2017 6029 "nissan,leaf,2012" 1 2017 6029 "nissan,leaf,2015" 3 2017 6029 "tesla,model s,2015" 1 2018 6029 "chevrolet,bolt ev,2017" 4 2018 6029 "kia,soul ev,2017" 1 2018 6029 "tesla,model s,2016" 1 2018 6029 "nissan,leaf,2015" 3 2018 6029 "nissan,leaf,2013" 1 2018 6029 "nissan,leaf,2017" 2 2018 6029 "tesla,model s,2015" 1 2019 6029 "nissan,leaf,2017" 2 2019 6029 "tesla,model s,2018" 1 2019 6029 "tesla,model s,2017" 1 2019 6029 "tesla,model s,2015" 1 2019 6029 "chevrolet,bolt ev,2017" 5 2019 6029 "tesla,model x,2018" 1 2019 6029 "tesla,model s,2016" 1 2019 6029 "tesla,model 3,2018" 4 2019 6029 "nissan,leaf,2015" 3 2020 6029 "tesla,model x,2018" 1 2020 6029 "tesla,model s,2018" 1 2020 6029 "tesla,model 3,2019" 8 end
Listed 30 out of 40 observations
Thank you,
Adam
Comment