Hi everyone,
I haven't used Stata for quite some time and now have a stupid question I fear.
I use survey data and have respondents with information on (among many others) the following variables: mig_year (Year they migrated to country X) sex (gender 0/1) and nation_1(Country of origin)
I now want to make a simple graph ( I thought of twoway with line) that shows the number of cases on the Y axis and the mig_year on the x-axis for Turkish and Italian immigrants separated by gender.
But now I'm a bit lost as to how to tell Stata what information it should take for the Y-axis.
The first data point would "simply" be the number of cases for female/male Turks/Italians in the year 19xx. So the result should be 4 lines (Turks male, Turks female, Italians male, Italians female) showing the number of cases over time.
I thought of something like that, but I just can't figure out how to tell Stata that y=number of cases. Do I need to gen a new variable that counts the obs? And if so, how do I do it?
I would really appreciate some help!
Best Carola
twoway (line y mig_year if sex==0 & nation_1=="Italy", ${suboptions} mlabel(nation_1) msymbol(d) color(red) xlabel(#10)) /// Italy Male
|| (line y mig_year if sex==1 & nation_1=="Italy", ${suboptions} mlabel(nation_1) msymbol(d) color(red) lpattern(dash) xlabel(#10)) /// Italy Female
|| (line y mig_year if sex==0 & nation_1=="Turkey", ${suboptions} mlabel(nation_1) msymbol(d) color(blue) xlabel(#10)) /// Turkey Male
|| (line y mig_year if sex==1 & nation_1=="Turkey", ${suboptions} mlabel(nation_1) msymbol(d) color(blue) lpattern(dash) xlabel(#10)) /// Turkey Female
|| , ${options} legend(order(1 "Italy Male" 2 "Italy Female" 3 "Turkey Male" 4 "Turkey Female") row(2)) title("Italy & Turkey by sex (without total)", size(medium) color(black))
I haven't used Stata for quite some time and now have a stupid question I fear.
I use survey data and have respondents with information on (among many others) the following variables: mig_year (Year they migrated to country X) sex (gender 0/1) and nation_1(Country of origin)
I now want to make a simple graph ( I thought of twoway with line) that shows the number of cases on the Y axis and the mig_year on the x-axis for Turkish and Italian immigrants separated by gender.
But now I'm a bit lost as to how to tell Stata what information it should take for the Y-axis.
The first data point would "simply" be the number of cases for female/male Turks/Italians in the year 19xx. So the result should be 4 lines (Turks male, Turks female, Italians male, Italians female) showing the number of cases over time.
I thought of something like that, but I just can't figure out how to tell Stata that y=number of cases. Do I need to gen a new variable that counts the obs? And if so, how do I do it?
I would really appreciate some help!
Best Carola
twoway (line y mig_year if sex==0 & nation_1=="Italy", ${suboptions} mlabel(nation_1) msymbol(d) color(red) xlabel(#10)) /// Italy Male
|| (line y mig_year if sex==1 & nation_1=="Italy", ${suboptions} mlabel(nation_1) msymbol(d) color(red) lpattern(dash) xlabel(#10)) /// Italy Female
|| (line y mig_year if sex==0 & nation_1=="Turkey", ${suboptions} mlabel(nation_1) msymbol(d) color(blue) xlabel(#10)) /// Turkey Male
|| (line y mig_year if sex==1 & nation_1=="Turkey", ${suboptions} mlabel(nation_1) msymbol(d) color(blue) lpattern(dash) xlabel(#10)) /// Turkey Female
|| , ${options} legend(order(1 "Italy Male" 2 "Italy Female" 3 "Turkey Male" 4 "Turkey Female") row(2)) title("Italy & Turkey by sex (without total)", size(medium) color(black))
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float mig_year byte sex str18 nation_1 1973 0 "Turkey" 1973 0 "Turkey" 1973 0 "Turkey" 1975 1 "Turkey" 1975 1 "Turkey" 1975 1 "Turkey" . 0 "Turkey" 1973 0 "Turkey" 1972 0 "Turkey" 1972 0 "Turkey" 1976 1 "Turkey" 1976 0 "Turkey" 1976 0 "Turkey" 1969 0 "Turkey" 1969 0 "Turkey" 1972 1 "Turkey" 1972 1 "Turkey" 1972 1 "Turkey" 1974 0 "Turkey" 1974 0 "Turkey" end label values sex sex label def sex 0 "male", modify label def sex 1 "female", modify
Comment