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

Generating a new variable - Stata Tutorial

From the course: Introduction to Stata 15

Start my 1-month free trial

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…

Contents