I am trying to create a panel dataset starting from cross-sectional data.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input long account str11(service supplystartdate) str10 supplyenddate 1 "A" "30/11/2018" "" 1 "B" "25/11/2017" "03/01/2019" 2 "A" "19/11/2017" "23/01/2019" 3 "A" "08/10/2017" "22/11/2018" 4 "A" "09/08/2017" "25/10/2017" 5 "A" "26/10/2016" "20/07/2017" 6 "A" "19/04/2014" "" 7 "A" "26/07/2015" "09/11/2019" 7 "B" "23/07/2015" "04/11/2019" 8 "A" "11/09/2013" "" 9 "A" "09/07/2015" "18/09/2019" end
The goal is to know, for each account, for how many days she has used a service (A and/or B).
However, for future analyses, rather than a single variable with values the number of days, I would need to systematically generate (and associate to each account) several dummy variables (starting from e.g. 11/09/2013 .. up to today, 14/01/2020) equal to 1 if the service was used in that day and 0 otherwise.
Indeed, in the end I will have to aggregate, for each day, the number of accounts using a service at a particular zipcode.
How can I do?
0 Response to Creating panel data from cross sectional data
Post a Comment