12-11-2014 11:21 AM
I have what is sort of like a transcript for classes with variables id, class, grade, credits, etc. Some of the classes are repeats within an id and I need to only count the class that was taken most recently in the GPA. Is there any way to not count the first of the repeats in the GPA, while still allowing the class to show on the transcript. I need to count the final class in the overall GPA.
12-11-2014 12:10 PM
Do you have a Date variable for each of the records involved? If so then a quick an dirty approach to subset the data could be:
proc sort data=have; by Id class date;run;
by id class ;
This would have the latest instance of each id and class combination.
BTW, you would want to set the values to missing not 0.
12-11-2014 12:56 PM
something like this?
proc sort data=have; by id class descending date;run;
retain QualityPoints num;
retain TotalCredits num;
if first.id then do;
if first.class then do;
if Grade='A' then QualityPoints+4;
else if Grade='B' then QualityPoints+3;
else if Grade='C' then QualityPoints+2;
else if Grade='D' then QualityPoints+1;
if last.id then GPA=QualityPoints / TotalCredits;