Announcement

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

  • Combine scalars in one variable to make a scatter plot

    Hi,

    I have 7 scalars which represent the means of the years of education for each time period. I want to combine these 7 scalars in a variable so that I can make a scatter plot of the means of education on the y-axis and the time period on the x-axis. I do not find a way to combine the 7 scalars in a variable. Can someone help me out?

  • #2
    That could be done but the more usual way to do it would be to use egen, mean() to put the means in a variable directly.

    Comment


    • #3
      I have different variables for which I calculated the mean and I put them into scalars because otherwise the variable duplicated the value for all the observations and that is not what I needed. But know I have to combine the scalars in a variable to use them in a scatter plot but I do not know how I can do this.

      Comment


      • #4
        It is indeed inefficient to store a mean repeatedly in a variable but for graphical purposes that often works fine. But I still don't see that you need to do anything like what you're describing.

        Here is a silly example of means of something by year.

        Code:
        . webuse grunfeld, clear
        
        . egen mean = mean(invest), by(year)
        
        . line mean year if company == 1, sort
        If that doesn't help, please post a minimal data example and sufficient code to make clear what you are doing.

        Comment


        • #5
          You can also the immediate version of the scatterplot command to plot scalars directly; see
          Code:
          help twoway scatteri

          Comment


          • #6
            Twoway scatteri was exactly what I was looking for! Thank you very much!

            Comment

            Working...
            X