data ex;
input
id:$10. price;
cards;
00846UAB7 101.84
00846UAB7 101.5
00846UAB7 100.564
00846UAB7 100.564
00846UAB7 100.563999
00846UAB7 100.563599
00846UAB7 100.365799
00846UAB7 100.283
00846UAB7 100.283
00846UAB7 100.283
013817AB7 112.144
013817AB7 112.144
013817AB7 112.275
013817AB7 112.189999
013817AB7 111.424
013817AB7 111.424
013817AB7 112.024
013817AB7 111.954999
013817AB7 111.329714
013817AB7 111.3297
;
run;
proc sort data=ex;
by id;
run;
data ex1;
set ex;
by id;
retain n;
p1=dif(price);
p2=lag(p1);
if first.id then do;
n=_n_;
delete;
end;
if _n_=n+1 then delete;
run;
ods listing close;
ods output cov=cov(drop=variable rename=(p1=cov));
proc corr data=ex1 cov;
by id;
var p1;
with p2;
run;