**********************************
*7. Recode a continuous variable *
to a categorical variable *
**********************************
cd "/Users/bobwen/Documents/2022 Youtube Teaching/Introductory Stata/7. Recode/"
capture log close
log using recode.log, text replace
sysuse auto.dta, clear
describe
summarize
*recode miles per gallon to categorical var
recode mpg (12/19=1) (20/29=2) (30/41=3), generate(mpg_ca)
tabulate mpg_ca
*recode weight to a dummy variable
recode weight (1760/3019=0) (3020/4840=1), generate(heavy)
tabulate heavy
log close
Some courses on my Youtube channel:
Introductory Stata:
• Introductory Stata (2022)
Introductory Microeconomics:
• Introductory Microeconomics (2022)
【粵語Cantonese】微觀經濟學基礎:
• 粵語Cantonese微觀經濟學基礎2022
Introductory Econometrics:
• Solutions to Introductory Econometrics A M...
Five Minute Econometrics:
• Five Minute Econometrics (Econometrics Tut...
【Mandarin國語】五分鐘計量經濟學
• 【Mandarin國語】五分鐘計量經濟學(計量經濟學輔導)
【Cantonese粵語】五分鐘計量經濟學
• 【Cantonese粵語】五分鐘計量經濟學(計量經濟學輔導)
On the Road:
• On the Road
My free online Stata course on Alison:
https://alison.com/course/introductor...
#recode #Stata