* Set up data for example; proc sort data=sashelp.class out=ByAge; by Age; run; proc transpose data=ByAge out=HeightsByAge(drop=_name_) prefix=Height; by Age; var Height; run; proc print data=HeightsByAge; id Age; title1 "HeightsByAge data set"; run; data SecondORDINAL; set HeightsByAge; SecondShortestUnadjusted=ordinal(2,of height:); if nmiss(of height:)=0 then SecondShortest=ordinal(2,of height:); else SecondShortest=ordinal(2+nmiss(of height:),of height:); run; proc print data=SecondORDINAL; id Age; title1 "Second Shortest found through ORDINAL function"; run;