Stata Graph

#1
Morning,

I am using stata for doing graph with command :
"twoway line variable1 variable2 timeVariable"

In my database, i have a lot of countries and, when stata do this graph for all the countries, the first point of every curve is joined to the last point of this same curve. Here you are my question : how can i delete this ?

Moreover, when i use the same command but for a specific country (like that : "twoway line variable1 variable2 timeVariable if country==1, title(country)"), i do not have this problem...

Thank you so much in advance,

Geoffrey
 
#2
The command

twoway line variable1 variable2 timeVariable

Stata doesn't know you have many countries. It only connects the two successive data points following the order of them in the data set.

You could see whether the command -twoway scatter, connect(connectstylelist)- with the connect style

ascending L direct, but only if x[j+1] > x[j]

helps. See -help scatter- and -help connectstyle-. Also, you may consider overlaying the graph for different countries, such as

twoway (line variable1 variable2 timeVariable ///
if country==1) ///
(line variable1 variable2 timeVariable ///
if country==2), title(country)
 

bukharin

RoboStataRaptor
#3
twoway (line variable1 variable2 timeVariable ///
if country==1) ///
(line variable1 variable2 timeVariable ///
if country==2), title(country)
This is what I normally do. Sometimes you have several groups (in your case countries) and it becomes inconvenient to type out the same command for each group. In such a situation the -separate- command can be quite handy:
Code:
separate variable1, by(country) gen(v1_)
separate variable2, by(country) gen(v2_)
line v1_* v2_* timeVariable, sort
 
#4
Thank you so much !!!

The option -connect (L)- work with the command -line-, so now my command is "twoway line variable1 variable2 timeVariable, connect(L)". And this is what i want !!!

The -seperate- command will help me for a lot of work!

Thank you both !

Geoffrey
 

bukharin

RoboStataRaptor
#5
You may want to make that:
... connect(L L)
(once for variable1, once for variable2)

Alternatively:
... connect(L ..)
(makes it L for all y variables)