Please see the attached data. I want to make a graph that has year on the x axis and %of ivf use on the y axis and the two lines to show the use with phi_bin. So essentially I want the graph to have two lines one for if phi_bin==1 and the other one for phi_bin=0.
I am using the following code provided by Nick Cox in a previous message :
egen toshow = mean(ivf), by(year phi_bin)
separate toshow, by(phi_bin) veryshortlabel
line toshow? year , ytitle(% of IVF users)
but it is not producing what I want, I only want two lines and not multiple as the code is doing. Any help is appreciated thanks!!
dataex year id ivf phi_bin
clear
input byte year double id float(ivf phi_bin)
4 700002 0 1
5 700002 0 1
7 700002 0 1
8 700002 0 1
4 700004 0 0
7 700004 0 1
4 700006 0 1
5 700006 0 0
6 700006 0 0
7 700006 0 0
8 700006 0 0
4 700007 0 1
5 700007 0 1
6 700007 0 1
7 700007 0 1
8 700007 0 1
6 700008 0 0
4 700009 0 0
6 700009 0 0
7 700009 0 1
8 700009 1 1
4 700010 0 0
7 700010 0 1
8 700010 0 1
4 700011 0 0
5 700011 0 0
6 700011 0 0
7 700011 0 1
8 700011 0 1
4 700012 0 0
5 700012 0 0
6 700012 0 0
8 700012 0 0
4 700016 0 1
5 700016 0 1
6 700016 0 1
7 700016 0 1
8 700016 0 1
4 700017 0 1
5 700017 0 0
6 700017 0 1
7 700017 0 1
4 700020 0 0
4 700022 0 1
5 700022 1 1
6 700022 1 1
7 700022 0 1
8 700022 0 1
4 700023 1 1
5 700023 0 1
6 700023 1 1
8 700023 . .
4 700024 0 0
6 700024 0 1
7 700024 0 1
8 700024 0 1
4 700025 0 0
5 700025 0 0
6 700025 0 0
7 700025 0 0
8 700025 0 0
4 700026 0 0
5 700026 0 0
6 700026 0 1
7 700026 0 1
4 700027 0 1
5 700027 0 1
6 700027 0 1
7 700027 0 1
8 700027 1 1
4 700030 0 1
5 700030 0 1
6 700030 0 1
7 700030 0 1
8 700030 0 1
4 700031 0 0
4 700032 0 1
6 700032 0 1
7 700032 0 1
8 700032 0 1
4 700033 0 0
4 700034 . 1
5 700034 0 1
6 700034 0 1
7 700034 0 1
8 700034 0 1
4 700037 0 1
5 700037 0 1
6 700037 0 1
7 700037 0 1
8 700037 0 1
4 700038 0 0
5 700038 0 1
6 700038 0 1
8 700038 . .
4 700039 0 1
5 700039 1 1
7 700039 1 1
4 700040 0 1
5 700040 0 0
end
label values ivf a
label def a 0 "IVF Non-User", modify
label def a 1 "IVF User", modify
[/CODE]
Thanks!
Related Posts with 3 way graph
Using local variable in forvalues loopHi everyone, I am trying to run the following code: count if productcode == 21 scalar nobs = r(N) …
Add string to empty cellHi all, I need add string (N/A) to empty cells for a string Variable, I used "subinstr", but lament…
Simple table export question: loop or by function?Hi everyone I am currently working on a monitoring and evaluation program where I need to create a …
Creating a more efficient loop for generating multiple datasetsHello Statalist, I am in the process of creating 718 different data files based off of one master d…
Calculating rate and confidence interval for a series of data.Hello all I am doing some time series stuff (using R to do interrupted time series analysis - long …
Subscribe to:
Post Comments (Atom)
0 Response to 3 way graph
Post a Comment