My current dataset resembles the following:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float(individual year ind1 ind2 ind3) 1 2019 1 2 2 2 2019 1 1 2 2 2019 1 1 1 2 2019 1 2 1 3 2019 1 1 1 3 2019 1 1 2 3 2019 1 1 2 3 2019 1 2 1 3 2019 1 2 2 3 2019 2 1 2 3 2019 2 2 1 3 2019 2 2 2 1 2020 1 2 1 2 2020 1 1 1 3 2020 1 1 2 end
Here, I have data by individuals, on a number of different indicator variables, for each year (2019 and 2020). These variables can take on 2 values. Given that there are 3 of them, the total number of distinct combinations of these variables are 2^3=8. Moreover, given that there are 2 years, the total number of observations per individual should be 16. As of now, rows where the individual data are missing are not included. That is, for 2019, individual 1 just has a single data point (combination 1-2-2).
I would like to expand this dataset to make it square. I.e. I would like there to be 16 observations per individual in total, with the individual-year cells populated for missing observations, but not the rest. Any help on this is much appreciated.
Best,
CS
0 Response to Expanding dataset to make it balanaced
Post a Comment