I have panel data, such as the following:
I use xtline to produce graphs of selected variables over time. I only include one panel using the following syntax:
This works fine. I want to add another variable on a different scale, so with a different Y-axis. I add the addplot options below:
Now Stata draws an xtline graph for each panel but only plots data for the first panelid, and I only want one graph of one panel.
What am I missing that will keep Stata from drawing the other (plotless) graphs?
Code:
clear input float(year panelid yvar yvar2) 1999 1 3 2 2000 1 5 2 2001 1 6 3 2002 1 5 3 1999 2 4 8 2000 2 8 8 2001 2 9 8 2002 2 9 8 1999 3 2 9 2000 3 1 9 2001 3 3 7 2002 3 4 6 end
xtline yvar if panelid==1
xtline yvar if panelid==1, addplot(tsline yvar2 if panelid==1, yaxis(2))
What am I missing that will keep Stata from drawing the other (plotless) graphs?
Comment