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.
Thanks!
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;
data want;
set have;
by id class ;
if last.class;
run;
This would have the latest instance of each id and class combination.
BTW, you would want to set the values to missing not 0.
something like this?
proc sort data=have; by id class descending date;run;
data want;
retain QualityPoints num;
retain TotalCredits num;
if first.id then do;
QualityPoints=0;
TotalCredits=0;
end;
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;
TotalCredits+Credits;
end;
if last.id then GPA=QualityPoints / TotalCredits;
run;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.