Announcement

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

  • Represent Table to Line graph

    Greetings.
    I would want to transform my tabulation: ta bdcategory year
    to be represented in a line graph where each value in the category is represented by its own line.
    I'll be very grateful for your assistance.

    Sample dataset extract below



    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input byte(bdcategory studyinterest) float(month year monthly)
     9 1 1 2019 708
    10 1 1 2018 696
     7 1 9 2018 704
     9 1 2 2017 685
     6 1 3 2016 674
    11 1 3 2017 686
     3 1 5 2016 676
    11 1 7 2018 702
     6 1 9 2017 692
     7 1 1 2018 696
    end
    format %tm monthly
    label values bdcategory bdcategory_
    label def bdcategory_ 3 "Ant Abd wall Omphalocoele", modify
    label def bdcategory_ 6 "MSK Talipes", modify
    label def bdcategory_ 7 "MSK limb reduction deficiencies", modify
    label def bdcategory_ 9 "NTD", modify
    label def bdcategory_ 10 "Oralfacial clefts", modify
    label def bdcategory_ 11 "Urogenital", modify
    label values studyinterest studyinterest_
    label def studyinterest_ 1 "Yes", modify
    label values month month
    label def month 1 "January", modify
    label def month 2 "February", modify
    label def month 3 "March", modify
    label def month 5 "May", modify
    label def month 7 "July", modify
    label def month 9 "September", modify

    Thanks
    R

  • #2
    Your data example shows 6 categories and I guess there are more. You could try

    Code:
    bysort bdcategory monthly : gen count = _N 
    line count monthly, by(bdcategory)
    but I don't understand what studyinterest is doing here.

    Comment


    • #3
      Thanks, Nick.
      There are surely more categories. I picked the first 10 records.
      Sorry, I forgot to remove "studyinterest" variable from the dataex command.
      Is it possible to have one line graph displaying all categories?

      Thanks
      R

      Comment


      • #4
        Yes, but it will be predictably an awful mess.

        Code:
        xtset bdcategory monthly 
        help xtline
        is one way forward in that direction.
        Last edited by Nick Cox; 29 May 2019, 06:16.

        Comment


        • #5
          Thanks.
          Very helpful

          Comment

          Working...
          X