From the course: Introduction to Stata 15
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Generating a new variable - Stata Tutorial
From the course: Introduction to Stata 15
Generating a new variable
- [Instructor] In the previous session we explored how to recode an existing variable. In this session we'll focus on how we can generate new variables. We'll look at how we can generate new variables by a computational combination of other variables. And we'll also look at how we can create new variables based on functional transformations. For example, taking the logarithm of price. We're going to introduce the generate command and the replace command. Both commands are actually identical except that generate allows us to generate new variables whilst replace allows us to change existing variables. So let's head over to Stata. Here we are in Stata with the autodata already loaded. Before we continue, it's worth having a look at the help file of generate. So let's type help generate. And here we can see the help file for generate. The syntax is displayed here. At first glance it might look relatively complex. But actually it's quite easy to use. We type generate and specify a new…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
(Locked)
Recoding an existing variable4m 3s
-
(Locked)
Generating a new variable5m 15s
-
(Locked)
Naming and labeling variables5m 20s
-
(Locked)
Extended generate3m 26s
-
(Locked)
Indicator variables4m 7s
-
(Locked)
Keeping and dropping variables3m 9s
-
(Locked)
Saving data3m 6s
-
(Locked)
Merging and appending6m 54s
-
(Locked)
String variables5m 53s
-
(Locked)
Local macros and looping7m 12s
-
(Locked)
Manipulating data: Challenge45s
-
(Locked)
Manipulating data: Solution4m 7s
-
(Locked)
-
-
-
-
-
-