Hi,
I have a panel dataset of around 500 units observed 10 times each. That it to mean that while in long format, my data has 5000 observations (rows). I want to generate individual unit datasets from this panel i.e. to end up with 500 data files each for every unit. Look at this MWE data;
I am unable to conceive a loop (for which I have been hoping it can work) which picks up data for unit 1 and saves it as say data1 and then does the same for unit 2 and saving it as data2 etc such that in the end, I have 3 dataset files in my working directory of the form;
Data 1
Data 2
Data 3
Could anyone please assist me?
Thanks
I have a panel dataset of around 500 units observed 10 times each. That it to mean that while in long format, my data has 5000 observations (rows). I want to generate individual unit datasets from this panel i.e. to end up with 500 data files each for every unit. Look at this MWE data;
Code:
id year income age tax 1 2000 3453 23 573 1 2001 7476 24 453 1 2002 7346 25 846 2 2000 9898 32 234 2 2001 6253 33 254 2 2002 6272 34 745 3 2000 9032 17 234 3 2001 8829 18 746 3 2002 2738 19 234
Data 1
Code:
id year income age tax 1 2000 3453 23 573 1 2001 7476 24 453 1 2002 7346 25 846
Code:
id year income age tax 2 2000 9898 32 234 2 2001 6253 33 254 2 2002 6272 34 745
Code:
id year income age tax 3 2000 9032 17 234 3 2001 8829 18 746 3 2002 2738 19 234
Could anyone please assist me?
Thanks
Comment