data stock; infile 'c:\temp\stock.txt'; input name$ price1 - price5; if price2 < price1 then do; n=2; ret=(price2-price1)/price1; end; else if price3 < price2 then do; n=3; ret=(price3-price1)/price1; end; else if price4 < price3 then do; n=4; ret=(price4-price1)/price1; end; else do; n=5; ret=(price5 - price1)/price1; end; proc print; run;