Hello everyone,
I have a minor problem which I hope someone can help me solve.
I am working with data on rental cars and aim to end up with a binomial variable indicating whether a given car is active or parked.
An example of my dataset is as follows:
Explanation: So for this example, Car No. 1 has been on rental from 01. January 2006 to 03. January 2006, and again from 04. January 2006 to 05. January 2006. Car No. 2 has been on rental from 01. January 2006 to 04. January 2006. Lastly, Car No. 3 only had a rental contract from 03. January 2006 to 04. January 2006
What I would like Stata to do for me is to fill in the blanks in an "Rental column" containing a dummy variable which is assigned the value "1" if the car is on rental and "0" if the car is parked, like this:
I really hope someone can be able to help with this, and would be very grateful for any tips that can lead me to solve it.
Regards,
Morten
I have a minor problem which I hope someone can help me solve.
I am working with data on rental cars and aim to end up with a binomial variable indicating whether a given car is active or parked.
An example of my dataset is as follows:
Date | CarID | StartContract | EndContract |
01.01.2006 | 1 | 1 | 0 |
01.02.2006 | 1 | 0 | 0 |
01.03.2006 | 1 | 0 | 1 |
01.04.2006 | 1 | 1 | 0 |
01.05.2006 | 1 | 0 | 1 |
01.01.2006 | 2 | 1 | 0 |
01.02.2006 | 2 | 0 | 0 |
01.03.2006 | 2 | 0 | 0 |
01.04.2006 | 2 | 0 | 1 |
01.05.2006 | 2 | 0 | 0 |
01.01.2006 | 3 | 0 | 0 |
01.02.2006 | 3 | 0 | 0 |
01.03.2006 | 3 | 1 | 0 |
01.04.2006 | 3 | 0 | 1 |
01.05.2006 | 3 | 0 | 0 |
What I would like Stata to do for me is to fill in the blanks in an "Rental column" containing a dummy variable which is assigned the value "1" if the car is on rental and "0" if the car is parked, like this:
Date | CarID | StartContract | EndContract | On rent (1/0) |
01.01.2006 | 1 | 1 | 0 | 1 |
01.02.2006 | 1 | 0 | 1 | 1 |
01.03.2006 | 1 | 0 | 0 | 0 |
01.04.2006 | 1 | 1 | 0 | 1 |
01.05.2006 | 1 | 0 | 1 | 1 |
01.01.2006 | 2 | 1 | 0 | 1 |
01.02.2006 | 2 | 0 | 0 | 1 |
01.03.2006 | 2 | 0 | 0 | 1 |
01.04.2006 | 2 | 0 | 1 | 1 |
01.05.2006 | 2 | 0 | 0 | 0 |
01.01.2006 | 3 | 0 | 0 | 0 |
01.02.2006 | 3 | 0 | 0 | 0 |
01.03.2006 | 3 | 1 | 0 | 1 |
01.04.2006 | 3 | 0 | 1 | 1 |
01.05.2006 | 3 | 1 | 0 | 0 |
Regards,
Morten
Comment