Announcement

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

  • STS Graph

    Click image for larger version

Name:	KM_Survival.jpg
Views:	1
Size:	224.0 KB
ID:	1623077 Hello Statalisters,

    I am creating a graph looking at the survival rates of Face Mask policies in the US and my K-M graph's x-axis goes all the way back to 1960 even though the policies were only in effect in 2020-21 (from the data I have collected). Is there anyway to force the x-axis to a range of dates? I've attached a sample of the data and the code below as well as the graph. Apologies for the large graphic.

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input str14 statename byte(_st _d) int(_t _t0) byte mandate_order_dates float daily_cases_by_date
    "Alaska" 1 0 21936     0 0 21936
    "Alaska" 1 0 21937 21936 0 21937
    "Alaska" 1 0 21938 21937 0 21938
    "Alaska" 1 0 21939 21938 0 21939
    "Alaska" 1 0 21940 21939 0 21940
    "Alaska" 1 0 21941 21940 0 21941
    "Alaska" 1 0 21942 21941 0 21942
    "Alaska" 1 0 21943 21942 0 21943
    "Alaska" 1 0 21944 21943 0 21944
    "Alaska" 1 0 21945 21944 0 21945
    "Alaska" 1 0 21946 21945 0 21946
    "Alaska" 1 0 21947 21946 0 21947
    "Alaska" 1 0 21948 21947 0 21948
    "Alaska" 1 0 21949 21948 0 21949
    "Alaska" 1 0 21950 21949 0 21950
    "Alaska" 1 0 21951 21950 0 21951
    "Alaska" 1 0 21952 21951 0 21952
    "Alaska" 1 0 21953 21952 0 21953
    "Alaska" 1 0 21954 21953 0 21954
    "Alaska" 1 0 21955 21954 0 21955
    "Alaska" 1 0 21956 21955 0 21956
    "Alaska" 1 0 21957 21956 0 21957
    "Alaska" 1 0 21958 21957 0 21958
    "Alaska" 1 0 21959 21958 0 21959
    "Alaska" 1 0 21960 21959 0 21960
    "Alaska" 1 0 21961 21960 0 21961
    "Alaska" 1 0 21962 21961 0 21962
    end
    format %td _t
    format %td _t0
    format %td daily_cases_by_date
    HTML Code:
    stset daily_cases_by_date, failure (mandate_order_dates) id(name)
    format _t %9.3g
    format _t %td
    format _t0 %td
    sts graph, by(demgov)


  • #2
    Code:
    sts graph, by(demgov)  tmin(`=td(1jan2020)')
    See

    Code:
    help sts graph
    for more on this option.

    Comment


    • #3
      Andrew Musau That worked a treat. Thanks again!

      Comment

      Working...
      X