data three;
set one;
by area type year;
retain lastcost;
if first.type then do;lastcost=cost;pct=0;end;
else do;pct=(cost-lastcost)/lastcost;lastcost=cost;end;
drop lastcost;
run;
data three;
set one;
by area type year;
retain lastcost;
if first.type then do;lastcost=cost;pct=0;end;/**同一个地区,一个生产方式如果第一次开始使用,增长率设为0 **/
else do;pct=(cost-lastcost)/lastcost;lastcost=cost;end;/**同一个地区,一个生产方式如果之前使用过,增长率=(该年的美元值-上一年的美元值)/上一年的美元值 **/
drop lastcost;
run;