PDA

View Full Version : how to create deltas



foxtrot
01-16-2009, 07:52 AM
I have four variables: S_No, a, b, c for an n = 100.
Each new S_No is a new, unique case.
There are no repeat measurements per S_No.

a is the variable of interest and I sort the entire data-set "by a" (default ascending).

Now what I want to build, given data is sorted "by a" is:
d = a2 - a1 (S_no = 1).... a100-a99 (S_No = 100)
(d1 can = a1, but d2...d99 should be a2-a1...a100-a99)
Likewise,
e = b2 - b1 (S_no = 1).... b100-b99 (S_No = 100)
f = c2 - c1 (S_no = 1).... c100-c99 (S_No = 100)

Thus, total n will decrease my n-1.
I get three delta values,
Data sorted by a.

How to do this? :shakehead

Many thanks whoever gets me sorted out. :)

vinux
01-16-2009, 10:29 AM
It is easy... Use Dif1 function.
Let Data1 is your dataset including S_No a b c and it is sorted by a.




data Data2;
set Data1;
d =dif1(a);
e=dif1(b);
f=dif1(c);
run;


if you don't want the first observarion then you can give condition like

if d ne .;

Regards
Rich

foxtrot
01-19-2009, 01:46 AM
Rich this is the second time you help me out. D:D Thanks and this website is real cool. Thanks a million folks. :tup: