Hello Stata-listers,
I am using coefplot with multiple models and am trying to get sample sizes listed on the right y-axis (each model has different sample sizes due to missing values and different time periods). I have code to pull the Ns, but can't figure out how to get it displayed. I am using the ymlab option with various local macros. But, for ease with this example, we can use simple text. So, for example, how can I modify the following code to display the strings: first, second, third, etc on the right y-axis for the first plot, and "fourth", "fifth", and "sixth" on the y-axis of the second plot. I hope that makes sense. I have attached a manually modified image to kind of show what I'm trying to do with the code below. I know that I can run two separate plots and combine them using grc1leg, however, the problem with that is that it will repeat the left y-axis labels, and if I remove them on the second plot, the aspect ratio of the two plots are different.

I am using coefplot with multiple models and am trying to get sample sizes listed on the right y-axis (each model has different sample sizes due to missing values and different time periods). I have code to pull the Ns, but can't figure out how to get it displayed. I am using the ymlab option with various local macros. But, for ease with this example, we can use simple text. So, for example, how can I modify the following code to display the strings: first, second, third, etc on the right y-axis for the first plot, and "fourth", "fifth", and "sixth" on the y-axis of the second plot. I hope that makes sense. I have attached a manually modified image to kind of show what I'm trying to do with the code below. I know that I can run two separate plots and combine them using grc1leg, however, the problem with that is that it will repeat the left y-axis labels, and if I remove them on the second plot, the aspect ratio of the two plots are different.
Code:
sysuse auto, clear reg trunk foreign gear_ratio if rep78 == 5 // Outcome = Trunk and sub-group = 4 estimates store trunk_s5 reg trunk foreign gear_ratio if rep78 == 4 // Outcome = Trunk and sub-group = 5 estimates store trunk_s4 reg mpg foreign gear_ratio if rep78 ==5 // Outcome = MPG and sub-group = 4 estimates store mpg_s5 reg mpg foreign gear_ratio if rep78 ==4 // Outcome = MPG and sub-group = 5 estimates store mpg_s4 reg turn foreign gear_ratio if rep78 ==5 // Outcome = Turn and sub-group = 4 estimates store turn_s5 reg turn foreign gear_ratio if rep78 ==4 // Outcome = Turn and sub-group = 5 estimates store turn_s4 label var trunk "Trunk" label var mpg "MPG" label var turn "Turn" #delimit ; coefplot (trunk_s4 \ mpg_s4 \ turn_s4, keep(foreign gear_ratio)), ymlab(1 "First" 2 "Second" 3 "Third", axis(2)) || (trunk_s5 \ mpg_s5 \ turn_s5, keep(foreign gear_ratio)), ymlab(1 "Fourth" 2 "Fifth" 3 "Sixth", axis(2)) || , eqrename(*_s4 = "" *_s5 = "") swapnames aseq eqlabels("Origin" "Gear Ratio") bylabels("Subgroup 4" "Subgroup 5") nooffset ; #delimit cr
Comment