Hello,
Suppose I have a dataset with person ID, day, and calories. I have another variable called ``treated'' which equals 1 if a person got some treatment and 0 otherwise.
I am thinking of having an xtline graph by ID, but for each line, I want it to be of a different color for different values of ``treated''.
Here is what I did:
clear all
sysuse xtline1.dta,clear
keep if person<3
*creating variable ``treated''
bysort person:gen temp=_n
drop if temp>100
gen treated=0
replace treated=1 if person==1 & temp>50
replace treated=1 if person==2 & temp>70
drop temp
xtset person day, daily
xtline calories,overlay
And here is what I got: (see g1.png in the attachment)
And here is what I want: (see g2).
I searched online but got answer yet. Any suggestions will be appreciated.
Thanks!
Marco
Suppose I have a dataset with person ID, day, and calories. I have another variable called ``treated'' which equals 1 if a person got some treatment and 0 otherwise.
I am thinking of having an xtline graph by ID, but for each line, I want it to be of a different color for different values of ``treated''.
Here is what I did:
clear all
sysuse xtline1.dta,clear
keep if person<3
*creating variable ``treated''
bysort person:gen temp=_n
drop if temp>100
gen treated=0
replace treated=1 if person==1 & temp>50
replace treated=1 if person==2 & temp>70
drop temp
xtset person day, daily
xtline calories,overlay
And here is what I got: (see g1.png in the attachment)
And here is what I want: (see g2).
I searched online but got answer yet. Any suggestions will be appreciated.
Thanks!
Marco
Comment