Hi Lan, It would make it convenient for community members to search through the forum if you break your questions to new discussions that warrants a new subject or a new solution. Anyway, no worries, Continuing on Art's code from the above, do another sort and typical transpose : proc sort data=have out=h; by acode year; run; data want; set h; by acode year; if first.year then coverage=1; else coverage+1; if last.year then output; run; proc sort data=want out=w; by year; run; data w; array a(25) _temporary_ ; call missing(of a{*}); do _n_= 1 by 1 until(last.year); set w; by year; a(_n_)=coverage; med_value=median(of a{*}); end; run; Sorry, i am too lazy to look through your "renamed additional requirement", so just took the names as it was in your original question.
... View more