To keep only the last record, use the LAST, opposite of FIRST. SUM() considers missing the equivalent of 0, whereas + with a missing value will return a missing value. If first.studentID then call missing(tcredithrs, tgradepts, gpa) If you use the SUM function instead of + you can set them to MISSING instead using CALL MISSING. Make sure to put it before you do the sums. You can use the FIRST/LAST logic, like below. RETAIN TGPACreditHrs 0 TCreditHrs 0 TGradePts 0 GPA 0 Shouldn't it get a value of 0 rather than a missing value?Īnd are all grades counted in the calculation of the GPA? Don't some/most schools omit grades like pass, no pass, withdraw, transfer and incomplete?Īs such, I think you might want something closer to: DATA GPAStats (KEEP = TCreditHrs TGradePts GPA STUDENT_ID) In addition to the suggestions you have already received, I think you may want to give the problem a little more thought.įor example, you don't include F in your grade format.