Announcement

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

  • line graph not showing all data

    I have created a series of line graphs that are by(state). However, for some reason, the box for Connecticut is empty despite there being data in those cells of the dataset. There are other places where I'm missing lines for data that exists for that state and year but Connecticut is showing no lines and has data for all years. Hopefully, someone can help fix this.

    Here is my code:
    Code:
    twoway(line grad_ratio_w year if year>2004 & year<2013, by(state) cmissing(n))(line grad_ratio_b year if year>2004 & year<2013, by(state) cmissing(n))(line grad_ratio_h year if year>2004 & year<2013, by(state) cmissing(n))(line grad_ratio_poc year if year>2004 & year<2013, by(state) cmissing(n))

  • #2
    You should get the same result with

    Code:
      
     twoway line grad_ratio_w  grad_ratio_b  grad_ratio_h  grad_ratio_poc  year if inrange(year, 2005, 2012), by(state) cmissing(n ..)


    or even

    Code:
      
     twoway line grad_ratio_* year if inrange(year, 2005, 2012), by(state) cmissing(n ..)




    Please show us results of the following.

    Code:
    describe state 
    
    list grad_ratio* year if inrange(year, 2005, 2012) & state == "CT"
    I have to guess how your state data are held. You may need a numeric condition.

    Comment


    • #3
      Nick,

      That last line of code did nothing. There is nothing to show you for an output. However, when I look in the data editor there is data there. That data was generated through a formula applying to the entire column so I don't understand why some data is not showing up and others are as they should all be formatted the same. Your first line of code did replicate what I had done with a simpler code so thank you for that. Now if I can just figure out why not all of the data is showing up in the graphs. Also, I can't do an asterisk for the end of the variable because there are other race variables I'm not including in this graph series so I have to specify exactly which variables.

      Comment


      • #4
        Understood, but you did not show the results of

        Code:
        describe state
        and you could follow up with those of

        Code:
        tab state

        It's late here, so I won't be looking at this for a while, but someone else may be able to help.
        Last edited by Nick Cox; 28 Aug 2020, 19:43.

        Comment


        • #5
          I was able to fix Connecticut based on running those to lines and finding out that one of the data sources had misspelled it. However there are still places where there are a couple years of data missing. For example, Arkansas's data from 2005-2007 doesn't populate on the graph.



          storage display value
          variable name type format label variable label
          ------------------------------------------------------------------------------------------------------
          state str31 %31s State

          . tab state

          State | Freq. Percent Cum.
          --------------------------------+-----------------------------------
          Alabama | 29 1.83 1.83
          Alaska | 29 1.83 3.66
          Arizona | 29 1.83 5.49
          Arkansas | 29 1.83 7.32
          California | 29 1.83 9.15
          Colorado | 29 1.83 10.98
          Connecticut | 29 1.83 12.81
          DC | 27 1.70 14.51
          Delaware | 29 1.83 16.34
          District of Columbia | 10 0.63 16.97
          Federal BOP | 26 1.64 18.61
          Florida | 29 1.83 20.44
          Georgia | 29 1.83 22.27
          Hawaii | 29 1.83 24.10
          Idaho | 29 1.83 25.93
          Illinois | 29 1.83 27.76
          Indiana | 29 1.83 29.59
          Iowa | 29 1.83 31.42
          Kansas | 29 1.83 33.25
          Kentucky | 29 1.83 35.08
          Louisiana | 29 1.83 36.91
          Maine | 29 1.83 38.74
          Maryland | 29 1.83 40.57
          Massachusetts | 29 1.83 42.40
          Michigan | 29 1.83 44.23
          Minnesota | 29 1.83 46.06
          Mississippi | 29 1.83 47.89
          Missouri | 29 1.83 49.72
          Montana | 29 1.83 51.55
          Nebraska | 29 1.83 53.38
          Nevada | 29 1.83 55.21
          New Hampshire | 29 1.83 57.03
          New Jersey | 29 1.83 58.86
          New Mexico | 29 1.83 60.69
          New York | 29 1.83 62.52
          North Carolina | 29 1.83 64.35
          North Dakota | 29 1.83 66.18
          Ohio | 29 1.83 68.01
          Oklahoma | 29 1.83 69.84
          Oregon | 29 1.83 71.67
          Pennsylvania | 29 1.83 73.50
          Puerto Rico | 10 0.63 74.13
          Rhode Island | 29 1.83 75.96
          South Carolina | 29 1.83 77.79
          South Dakota | 29 1.83 79.62
          State prison total | 26 1.64 81.26
          Tennessee | 29 1.83 83.09
          Texas | 29 1.83 84.92
          US prison total (state+federal) | 26 1.64 86.56
          United States | 10 0.63 87.19
          Utah | 29 1.83 89.02
          Vermont | 29 1.83 90.85
          Virginia | 29 1.83 92.68
          Washington | 29 1.83 94.51
          West Virginia | 29 1.83 96.34
          Wisconsin | 29 1.83 98.17
          Wyoming | 29 1.83 100.00
          --------------------------------+-----------------------------------
          Total | 1,585 100.00

          Comment


          • #6
            Also, even if I use the state id variable instead of state in the by option it gives me the same result. So, it doesn't matter if it is string or numeric I get the same result.

            Comment


            • #7
              Thanks for all the help. I have come up with an alternative rather than a line graph.

              Comment


              • #8
                #6 is correct. The line graph problem should still be soluble. You have yet to give the results of say


                Code:
                  
                 list grad_ratio_w  grad_ratio_b  grad_ratio_h  grad_ratio_poc  year if inrange(year, 2005, 2012) & substr(state, 1, 4) == "Conn"
                which I need for further diagnosis;
                Last edited by Nick Cox; 29 Aug 2020, 03:00.

                Comment


                • #9
                  It turned out to be missing data that I missed when evaluating the data and cleaning it up. Thank you for all of the help.

                  Comment

                  Working...
                  X