Dear all,
I am relatively new to stata (and on the list) and need some help with an issue i have.
I have a data set created from merging a bunch of data files on car registration from the Netherlands. The data files have been collected each month from Nov 2017 to Aug 2018, and have 3 date variables: 1) The date when the car was new from factory, 2) The date when the car was first registered in the NL and 3) The date the car was last re-registered.
The two first dates are always the same, but the last one changes between the monthly data files (when for example a car is sold, exported and so on). I have an interest in looking at how many times a car changes owner based on how the registration date changes.
I managed to create a variable for the nb of sales by looking at if the dates differ by:
generate transaction = 0
forvalues i=1(1)21 {
local j = `i'+1
replace transaction= `i' if Date`i' < Date`j' & scrp_status ==0
}
Where scrp_status is a dummy for if the car is scrapped or not (sorry for the ugly code input). The id variable i used for the merging etc is the cars segregationist number
The problem is that sometimes the date changes more than once for a car between Nov 2017 and Aug 2019 which i can't capture with the code above, and i don't know how to proceed...
Any ideas or input is very very welcome!!
Many thanks
Elin
I am relatively new to stata (and on the list) and need some help with an issue i have.
I have a data set created from merging a bunch of data files on car registration from the Netherlands. The data files have been collected each month from Nov 2017 to Aug 2018, and have 3 date variables: 1) The date when the car was new from factory, 2) The date when the car was first registered in the NL and 3) The date the car was last re-registered.
The two first dates are always the same, but the last one changes between the monthly data files (when for example a car is sold, exported and so on). I have an interest in looking at how many times a car changes owner based on how the registration date changes.
I managed to create a variable for the nb of sales by looking at if the dates differ by:
generate transaction = 0
forvalues i=1(1)21 {
local j = `i'+1
replace transaction= `i' if Date`i' < Date`j' & scrp_status ==0
}
Where scrp_status is a dummy for if the car is scrapped or not (sorry for the ugly code input). The id variable i used for the merging etc is the cars segregationist number
The problem is that sometimes the date changes more than once for a car between Nov 2017 and Aug 2019 which i can't capture with the code above, and i don't know how to proceed...
Any ideas or input is very very welcome!!
Many thanks
Elin
Comment