Three Ways to Create Dummy Variables in Stata | Data Management | Stata Tutorials Topic 32

Dr. Bob Wen (Stata, Economics, Econometrics)
Dr. Bob Wen (Stata, Economics, Econometrics)
854 بار بازدید - 6 ماه پیش - Stata Tutorials Topic 32: Three
Stata Tutorials Topic 32: Three Ways to Create Dummy Variables in Stata | Summary Statistics and Data Management Using Stata

Hi, I am Bob. Welcome to the Stata course on data management. Let's talk about how to create dummy variables in Stata. A dummy variable is also called a binary variable or an indicator variable. It takes on only two values, zero and one. These two values are used to put each observation into one of two groups represented by zero and one. For example, we can use a dummy variable to describe whether a worker is full-time or part-time. We use a dummy variable, "full-time," to indicate full-time workers. Fulltime==1 means full-time workers; fulltime==0 represents part-time workers.

There are three main methods to create dummy variables in Stata. We can use the generate and replace commands to create a dummy variable based on an existing continuous variable. We can also use the recode command with the generate option. The third method is to create several dummy variables from a categorical variable using the tabulate command with the generate option.

Please download the BOB.dta dataset:
https://drive.google.com/file/d/1dUBB...

The Stata commands in this video:
*create a dummy variable using generate and replace commands
codebook schooling

generate college=0 if schooling . \\there is a "less than" sign between "schooling" and "."

replace college=1 if schooling 12 & schooling . \\there is a "greater than" sign between "schooling" and "12"; there is a "less than" sign between "schooling" and "."

tabulate college

summarize schooling

*create a dummy variable using recode command with generate option
recode schooling (6/12=0) (13/17=1), generate(college2)

tabulate college2

*create dummy variables from a categorical variable
tabulate race

tabulate race, nolabel

tabulate race, generate(racedummy)

tabulate racedummy1

tabulate racedummy2

tabulate racedummy3

tabulate racedummy4

display racedummy1+racedummy2+racedummy3+racedummy4

regress lwage racedummy*

【Some Free Courses on my YouTube Channel】

Economics in Real Life:
Economics in Real Life

Solutions to Introductory Econometrics A Modern Approach 7th Edition:
Solutions to Introductory Econometric...

Solutions to Microeconomics Theory and Applications with Calculus:
Solutions to Microeconomics Theory an...

Introductory Stata:
Introductory Stata (2022)

Introductory Microeconomics:
Introductory Microeconomics (2022)

Five Minute Econometrics:
Five Minute Econometrics (Econometric...

Five Minute Stata:
Stata Tutorials

【國語Mandarin】現實生活中的經濟學:
【Mandarin國語】現實生活中的經濟學

【粵語Cantonese】現實生活中的經濟學:
【Cantonese粵語】現實生活中的經濟學

【粵語Cantonese】微觀經濟學基礎:
粵語Cantonese微觀經濟學基礎2022

【國語Mandarin】五分鐘計量經濟學:
【Mandarin國語】五分鐘計量經濟學(計量經濟學輔導)

【粵語Cantonese】五分鐘計量經濟學:
【Cantonese粵語】五分鐘計量經濟學(計量經濟學輔導)

On the Road:
On the Road

【Become a Supporter of the channel ($2.99) to get PDF transcripts for】
1. Solutions to Microeconomics Theory and Applications with Calculus 5th Edition,
2. Solutions to Introductory Econometrics A Modern Approach 7th Edition,
3. Introductory Stata (2022), and
4. Introductory Microeconomics (2022).
@bobwenecon

#Stata #dummyvariable #DataManagement #SummaryStatistics #tutorial
6 ماه پیش در تاریخ 1402/11/09 منتشر شده است.
854 بـار بازدید شده
... بیشتر