data want; set have; by permno; pctn_change=dif(assets_total)/lag(assets_total); if first.permno then pctn_change=.; run;
The DIF function is defined as DIF(x) == x-LAG(x).
The SET with a BY statement provides a dummy to identify when the record in hand is the start (first.permno) or end (last.permno) of a sequence of records with the same permno. So the IF statement sets pctn_change to missing to prevent contamination from the prior permno.
... View more