Hi Ashwini, If i understand correctly, you want to find out second high score and high score of each student using First.Obs and last.Obs concept. For this, I have sorted the data by name and score in ascending order (the default working of proc sort and then used it with SET statement with BY keyword. I have made use of LAG function to accomplish the task. I hope the below program will address your query and if required with little changes. But below mentioned may not be close to ansewer but yes it may help you. data test; input name$ roll mark; datalines; A 1 200 A 3 800 A 5 400 A 6 100 B 7 300 B 2 800 B 4 700 B 6 900 B 1 100 C 2 300 C 3 100 C 4 600 C 5 800 ; run; proc sort data = test out = test; by name, marks; run; data _null_; set test; by name; if last.name ; secondhigh = lag(score); high = score; out put; run; proc print data = test; run;
... View more