Announcement

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

  • Frequencie graphs by year with string variables

    Hi all. I have imported a spreadsheet from excel, with the following variables: Type of surgery (string) date (date). Since then, I created a new date_var, and filled it with the date, formated as Year. I can use the flexible tables to creste a table that summarizes the type of surgery per year, and have totals for the column and row. What I can't figure out is how to do a bar graph that shows the frequencies of Type of surgery (totals) per Year. Any hints? Will I have to recode the type of surgery, and then use value labels back in the generated numerical variable? There should be something better... Thanks, Andre

  • #2
    Is this what you want?

    Code:
    clear
    set obs 100
    gen surgery=char(64+ceil(4*uniform()))
    gen year = 2000+ceil(3*uniform())
    tab2 surgery year
    
    generate one=1
    graph bar (count) one , over(year) over(surgery)

    Comment


    • #3
      Also check out -catplot- from SSC.

      Comment


      • #4
        Originally posted by Nick Cox View Post
        Also check out -catplot- from SSC.
        I find your paper on graphing categorical and compositional data quite useful. Presumably, tabplot (SSC) could also offer some interesting solutions.
        Kind regards,
        Konrad
        Version: Stata/IC 13.1

        Comment


        • #5
          Thanks a lot Juul, seems I'm in the right way! Now I have to figure out how to limit to year grouping. What's the purpose of the one var ?
          I'll check the catplot module too!

          Comment


          • #6
            I'm not sure if I follow, but you have two over statements so you will get two groupings. Use your comments with one over statement and you will get one grouping.
            Kind regards,
            Konrad
            Version: Stata/IC 13.1

            Comment


            • #7
              Konrad, you're a genius! (8-) Your hint worked with catplot...
              Seriously, thanks, I'm a beginner in Stata and I foresee a long way ahead...
              Will read that paper!

              Comment

              Working...
              X