Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help with line graphs

    Hello,

    Could someone kindly help with plotting a graph showing trends of time. This is a study looking at age-adjusted prevalence of asthma from 2005/6 to 2017/18. I am trying to create a graph trend with proportion on the y-axis and year on x-axis, with a line connecting proportion during each cycle. Also, how does one plot trends stratified by a third variable, race for example?
    I'm using the NHANES database and because it's a 2-yr cycle, I'm unclear as to how to label the x-axis to reflect the 2-year cycles.
    I would be grateful if anyone in this community could help.


    Rows: row number
    Year: NHANES cycle years
    Proportion: national estimate per cycle
    SE: Standard error
    low: Lower limit of CI
    high: Upper limit of CI

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input byte Rows str7 Year double(Proportion SE low high)
    1 "2005-6"  12.47344 1.391377 9.715774  15.2311
    2 "2007-8"  11.66398 .6140856 10.44689 12.88108
    3 "2009-10" 13.22848 1.052125  11.1432 15.31376
    4 "2011-12"  13.7035 1.013246 11.69528 15.71172
    5 "2013-14" 14.25656 .8406718 12.59038 15.92275
    6 "2015-16" 16.80714 1.920966 12.99985 20.61443
    7 "2017-18" 19.08004 1.282349 16.53846 21.62161
    end

    Code tried:
    set scheme s1mono
    encode Year, gen(year)
    twoway (rcap low high Rows, vert) (scatter Proportion year, sort connect(l))

    output::
    Click image for larger version

Name:	trends asthma.png
Views:	2
Size:	66.5 KB
ID:	1602947
Working...
X