Dear all,
I am trying to make a time-series graph showing count of events; by quarter; in groups who received; or did not receive an intervention (coded as a binary variable; this is the first step but there will be others). An example of my data is copied below.
Using some code from Nick Cox from this forum, this is possible by:
But this is not really practical for making many exploratory graphs. I would like a solution which I can easily manipulate, something like:
but I cannot see how to do this with counts.
Ideally I would prefer not to collapse the data unless this is really the simplest solution.
Any advice would be much appreciated.
Josh.
I am trying to make a time-series graph showing count of events; by quarter; in groups who received; or did not receive an intervention (coded as a binary variable; this is the first step but there will be others). An example of my data is copied below.
Using some code from Nick Cox from this forum, this is possible by:
Code:
egen no_int = count(int) if int==0, by(date_quart) egen yes_int = count(int) if int==1, by(date_quart) egen tag = tag(date_quart) twoway line no_int yes_int date_quart if tag, sort
Code:
twoway (line int date_quart if int == 0) (line int date_quart if int == 0)
Ideally I would prefer not to collapse the data unless this is really the simplest solution.
Any advice would be much appreciated.
Josh.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str5 Agegroup str6 Sex float(intervention date_quart) "20-24" "Female" 0 231 "00-04" "Male" 0 231 "00-04" "Female" 0 231 "00-04" "Female" 0 231 "00-04" "Female" 0 231 "70-74" "Male" 0 231 "15-19" "Male" 1 231 "40-44" "Male" 0 231 "85+" "Female" 0 231 "00-04" "Male" 0 231 "25-29" "Female" 0 231 "20-24" "Male" 0 231 "25-29" "Male" 0 231 "25-29" "Male" 0 231 "75-79" "Female" 0 231 "00-04" "Male" 0 231 "60-64" "Male" 0 231 "00-04" "Female" 0 231 "60-64" "Female" 0 231 "80-84" "Female" 0 231 "25-29" "Male" 0 230 "15-19" "Male" 1 230 "15-19" "Male" 1 230 "20-24" "Female" 0 230 "00-04" "Female" 0 230 "00-04" "Male" 0 230 "75-79" "Male" 0 230 "15-19" "Male" 1 230 "00-04" "Male" 0 230 "25-29" "Male" 0 230 end format %tq!Qq-CCYY date_quart
Comment