Hi:
Without seeing ALL of the actual code that you are submitting, it really is just a guessing game. Also useful would be to see a sample of your input data and a concrete example of exactly what you mean when you say that the two variables are "not moving in synchronous fashion" but are "moving in opposite direction to each other."
For example, if I run this program:
[pre]
proc sort data=sashelp.class out=class;
by sex;
run;
data cumage;
set class;
by sex;
retain cumtot cumcnt ovtot ovcnt;
if _n_ = 1 then do;
ovtot = 0;
ovcnt = 0;
end;
if first.sex then do;
cumtot = 0;
cumcnt = 0;
end;
cumtot + age;
cumcnt + 1;
ovtot + age;
ovcnt + 1;
run;
ods listing close;
ods html file='c:\temp\cumage.html' style=sasweb;
proc print data=cumage;
title 'Show cumulative variables';
var name sex age cumtot cumcnt ovtot ovcnt;
run;
ods html close;
[/pre]
Then the output clearly shows that the retained variables are not "moving in opposite directions to each other" -- CUMTOT does contain the cumulative values for age and CUMCNT does contain a cumulative frequency count -- for each gender and OVTOT and OVCNT -- which were not reset do contain the overall cumulative total for all the ages and the overal cumulative count.
cynthia
[pre]
Show cumulative variables
Obs Name Sex Age cumtot cumcnt ovtot ovcnt
1 Alice F 13 13 1 13 1
2 Barbara F 13 26 2 26 2
3 Carol F 14 40 3 40 3
4 Jane F 12 52 4 52 4
5 Janet F 15 67 5 67 5
6 Joyce F 11 78 6 78 6
7 Judy F 14 92 7 92 7
8 Louise F 12 104 8 104 8
9 Mary F 15 119 9 119 9
10 Alfred M 14 14 1 133 10
11 Henry M 14 28 2 147 11
12 James M 12 40 3 159 12
13 Jeffrey M 13 53 4 172 13
14 John M 12 65 5 184 14
15 Philip M 16 81 6 200 15
16 Robert M 12 93 7 212 16
17 Ronald M 15 108 8 227 17
18 Thomas M 11 119 9 238 18
19 William M 15 134 10 253 19
[/pre]
... View more