Hi, I am trying to compare values in different observations in
different variables.
Whenever there is value on Price A,I would like to compare the value
on Price A to the last values that shows before "." on Price B and
Price C.
For example, compare obs 4 on Price A to obs3 Price B and obs3 Price C.
compare obs10 value on Price A to obs9 Price B and obs9 Price C
compare obs11 value on Price A to obs9 Price B and obs9 Price C
Since they are not in same line, I am having hard time comparing them. I
used lag function to line up on those values in different variables
but it doesn't work in obs 10 and obs 11 or obs 25,26,27 case.
EX:
if price A ^="." then do;
If price A (obs4) >= Price C(obs3) then Cnt = "+";
If price A (obs4)<= Price B (obs3) then Cnt = "-";
end;
DataSet
obs Price A Price B Price C
1 . 1115.75 1116
2 . 1115.75 1116
3 . 1115.75 1116
4 1115 . .
5 . 1115.75 1116
6 1116 . .
7 . 1115.75 1116
8 . 1115.75 1116
9 . 1115.75 1116
10 1116.5 . .
11 1116 . .
12 . 1115.75 1116
13 . 1115.75 1116
14 . 1115.75 1116
15 1116 . .
16 . 1115.75 1116
17 . 1115.75 1116
18 . 1115.75 1116
19 . 1115.75 1116
20 1116 . .
21 . 1115.75 1116
22 . 1115.75 1116
23 . 1115.75 1116
24 . 1115.75 1116
25 1116 . .
26 1116.25 . .
27 1116.5 . .
28 . 1115.75 1116.5
29 1116.5 . .