Students take 4 tests and a final exam. I replace the lowest test grade with the final exam grade. If the final exam is the lowest grade, nothing happens. If there is a tie between the 2 lowest grades, I don't care which one involved in the tie gets replaced.
Example:
data before applying the substitution
test1 test2 test3 test4 final
88 90 100 50 75
90 55 70 100 50
data after applying the substitution
test1 test2 test3 test4 final
88 90 100 75 75
90 55 70 100 50
Hi @GreggB,
Try this:
data have;
input test1-test4 final;
cards;
88 90 100 50 75
90 55 70 100 50
;
data want;
set have;
array g[*] test1--final;
g[whichn(min(of g[*]), of g[*])]=final;
run;
Hi @GreggB,
Try this:
data have;
input test1-test4 final;
cards;
88 90 100 50 75
90 55 70 100 50
;
data want;
set have;
array g[*] test1--final;
g[whichn(min(of g[*]), of g[*])]=final;
run;
I would want to replace one of them. It wouldn't matter which one.
what if there are two 50 in the first obs ?
data have; input test1-test4 final; cards; 88 90 100 50 75 90 55 70 100 50 ; data want; set have; array g{*} test1--test4; do i=1 to dim(g); g{i}=max(g{i},final) ; end; drop i; run;
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: