Appending and merging the files for data management
Now, let's discuss how to work with more than one file. We will create two data files and combine them in different ways.
Let's create the first data file in Stata:
input fridge_model_id str10 model cost 1 "model 1" 12000 2 "model 2" 20000 3 "model 3" 40000 End Save fridge_model, replace List
![Appending and merging the files for data management](https://static.packt-cdn.com/products/9781782173175/graphics/graphics/B00646_02_15.jpg)
Let's create the second dataset:
Clear Input fridge_model_id str10 model cost 1 "model 4" 42000 2 "model 5" 52000 3 "model 6" 62000 End Save fridge_model2, replace List
![Appending and merging the files for data management](https://static.packt-cdn.com/products/9781782173175/graphics/graphics/B00646_02_16.jpg)
Now, let's append the two files we created:
![Appending and merging the files for data management](https://static.packt-cdn.com/products/9781782173175/graphics/graphics/B00646_02_17.jpg)
use fridge_model, clear append using fridge_model2
![Appending and merging the files for data management](https://static.packt-cdn.com/products/9781782173175/graphics/graphics/B00646_02_18.jpg)
Now, let's take the fridge_model data that has been prepared and sort it by fridge_model_id:
use fridge_model, clear sort fridge_model _id save fridge_model3 list
![Appending and merging the files for data management](https://static.packt-cdn.com/products/9781782173175/graphics/graphics/B00646_02_19.jpg)
Let's create the second dataset for these models:
clear input fridge_model_id str10 length width 1 100 200 2 150 300 3 200 400 end sort fridge_model_id...