Announcement

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

  • Grade point average in dataset where there is different number of grades for each individual

    I have a dataset in which 'id' shows the id-number of the individual, and 'grade' shows a grade in a subject for the individual. The number of grades available for each individual in my dataset differs between individuals. My data looks something like this:

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input byte(id grade)
    1 1
    1 2
    1 1
    2 3
    2 3
    3 4
    3 5
    3 6
    3 7
    4 8
    4 9
    5 3
    5 5
    5 2
    5 3
    5 4
    end

    I need to make a variable showing the grade point average for each individual. Any suggestions?
    Last edited by Emil Alnor; 08 Mar 2022, 10:16.

  • #2
    Code:
    help egen
    and look at the "mean()" function in that help file

    Comment


    • #3
      Originally posted by Rich Goldstein View Post
      Code:
      help egen
      and look at the "mean()" function in that help file
      So
      Code:
      by id: gen mean = mean(grade)
      ?

      Comment


      • #4
        No; as said you need egen. It’s a command allowing various of its own functions to be called. mean() is one such, and that’s not a function that will work with generate.

        Comment

        Working...
        X