Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Data Analysis with STATA

You're reading from   Data Analysis with STATA Explore the big data field and learn how to perform data analytics and predictive modelling in STATA

Arrow left icon
Product type Paperback
Published in Oct 2015
Publisher Packt
ISBN-13 9781782173175
Length 176 pages
Edition 1st Edition
Arrow right icon
Toc

Table of Contents (11) Chapters Close

Preface 1. Introduction to Stata and Data Analytics FREE CHAPTER 2. Stata Programming and Data Management 3. Data Visualization 4. Important Statistical Tests in Stata 5. Linear Regression in Stata 6. Logistic Regression in Stata 7. Survey Analysis in Stata 8. Time Series Analysis in Stata 9. Survival Analysis in Stata Index

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

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

Now, let's append the two files we created:

Appending and merging the files for data management
use fridge_model, clear
append using fridge_model2
Appending and merging the files for data management

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

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...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime