So how do you define 'permanent' ? If it is the second last product ,it should be permanent ,otherwise 'temporary' ?
data have;
input date $ Product $;
cards;
jan a
feb a
mar a
apr b
may b
june b
jul b
aug b
sep b
ovt b
nov b
dec b
;
data temp;
do until(last.product);
set have;
by product notsorted;
if first.product then date_start=date;
end;
date_end=date;
keep product date_start date_end ;
run;
data temp;
set temp nobs=nobs;
n=nobs;
run;
data want;
merge temp temp(firstobs=2 keep=product rename=(product=p));
from=product;to=p;
if _n_=n-1 then change='permanent';
else change='temporary ';
if _n_ ne n then output;
drop product p n;
run;
... View more