1

How do I label/rename the variables on y axis?

sysuse auto, clear
regress price mpg trunk length turn if foreign==0
estimates store Option1
regress price mpg trunk length turn if foreign==1
estimates store Option2
coefplot Option1 Option2, drop(_cons) xline(1)

None of the option in this coefplot: Putting names of regressions on y-axis is what I want. I want to to change Mileage (mpg) to Mileage and so on.

Edit: Sorry for not being clear in my question. I want to label variables on y axis like this:

sysuse auto, clear 

keep if rep78>=3 

regress mpg headroom i.rep##i.foreign 

coefplot, xline(0) omitted baselevels drop(_cons) /// 
headings(3.rep78 = "{bf:Repair Record}" /// 
0.foreign = "{bf:Car Type}" /// 
3.rep78#0.foreign = "{bf:Interaction Effects}") headings(3.rep78 = "{bf:Repair Record}" /// 

I got this error message:

command headings is unrecognized r(199); – 
Nick Cox
  • 35,529
  • 6
  • 31
  • 47
Quinn
  • 9
  • 6
  • My guess is that you're using `///` interactively. Evidently Stata thinks that `headings` is a command in your view and it can't find any such. `///` is only allowed in do-files and programs. Interactively omit the `///` and type the command as one. – Nick Cox May 12 '22 at 09:21

1 Answers1

1

rename works fine for me. Maybe you referred to variable labels instead of the variable names in rename before?

coefplot Option1 Option2, drop(_cons) xline(1) rename(mpg = Mileage)
Wouter
  • 3,201
  • 6
  • 17
  • Sorry for not being clear in my question. I want to label variabels on y axis like this: sysuse auto, clear keep if rep78>=3 regress mpg headroom i.rep##i.foreign coefplot, xline(0) omitted baselevels drop(_cons) /// headings(3.rep78 = "{bf:Repair Record}" /// 0.foreign = "{bf:Car Type}" /// 3.rep78#0.foreign = "{bf:Interaction Effects}") headings(3.rep78 = "{bf:Repair Record}" /// command headings is unrecognized r(199); – Quinn Mar 03 '22 at 18:45
  • 1
    Please update your question with the new code, this is hard to read – Wouter Mar 04 '22 at 09:37