Hello, I've been using retain to create a rolling summary of unit1 (see units1), what I need to do now is stop this rolling summary so I can use 'IF.LAST.covref' to give me lines I'm after i.e. obs8 obs16 obs23 obs30 (there are other variables but I can't fit them in here) to give me the sum of the 'Unit1', i.e. sum of obs 1 to 8 =725.39, sum of obs 9 to 16 =565.840, sum of obs 17 to 23 =18.068, sum of obs 26 to 32 =18.137 etc.
My retain code looks like this, is there a way of putting a break in the rolling sum of units1, I need an if then do statement at the top of it, nothing I've tried has worked yet?
Data temp;
set a1;
by polref inrref covref;
retain x;
x=max(x,unit1);
units1 + unit1;
Obs POLREF INRREF COVREF unit1 units1
1 91536890 1 1 -0.302 -0.3
2 91536890 1 1 -3.188 -3.49
3 91536890 1 1 -6.277 -9.77
4 91536890 1 1 -2.961 -12.73
5 91536890 1 1 140.724 128
6 91536890 1 1 323.72 451.72
7 91536890 1 1 232.237 683.95
8 91536890 1 1 41.432 725.39
9 91536890 2 1 -0.238 725.15
10 91536890 2 1 -2.488 722.66
11 91536890 2 1 -4.887 717.77
12 91536890 2 1 -2.31 715.46
13 91536890 2 1 109.769 825.23
14 91536890 2 1 252.512 1077.74
15 91536890 2 1 181.152 1258.9
16 91536890 2 1 32.325 1291.22
17 91536890 3 1 -0.074 1291.15
18 91536890 3 1 -0.159 1290.99
19 91536890 3 1 -0.076 1290.91
20 91536890 3 1 2.346 1293.26
21 91536890 3 1 8.989 1302.25
22 91536890 3 1 6.449 1308.7
23 91536890 3 1 0.593 1309.29
24 91536890 3 2 -0.074 1309.22
25 91536890 3 2 -0.159 1309.06
26 91536890 3 2 -0.076 1308.98
27 91536890 3 2 2.355 1311.34
28 91536890 3 2 9.023 1320.36
29 91536890 3 2 6.473 1326.83
30 91536890 3 2 0.595 1327.43
Thanks
Scott
My retain code looks like this, is there a way of putting a break in the rolling sum of units1, I need an if then do statement at the top of it, nothing I've tried has worked yet?
Data temp;
set a1;
by polref inrref covref;
retain x;
x=max(x,unit1);
units1 + unit1;
Obs POLREF INRREF COVREF unit1 units1
1 91536890 1 1 -0.302 -0.3
2 91536890 1 1 -3.188 -3.49
3 91536890 1 1 -6.277 -9.77
4 91536890 1 1 -2.961 -12.73
5 91536890 1 1 140.724 128
6 91536890 1 1 323.72 451.72
7 91536890 1 1 232.237 683.95
8 91536890 1 1 41.432 725.39
9 91536890 2 1 -0.238 725.15
10 91536890 2 1 -2.488 722.66
11 91536890 2 1 -4.887 717.77
12 91536890 2 1 -2.31 715.46
13 91536890 2 1 109.769 825.23
14 91536890 2 1 252.512 1077.74
15 91536890 2 1 181.152 1258.9
16 91536890 2 1 32.325 1291.22
17 91536890 3 1 -0.074 1291.15
18 91536890 3 1 -0.159 1290.99
19 91536890 3 1 -0.076 1290.91
20 91536890 3 1 2.346 1293.26
21 91536890 3 1 8.989 1302.25
22 91536890 3 1 6.449 1308.7
23 91536890 3 1 0.593 1309.29
24 91536890 3 2 -0.074 1309.22
25 91536890 3 2 -0.159 1309.06
26 91536890 3 2 -0.076 1308.98
27 91536890 3 2 2.355 1311.34
28 91536890 3 2 9.023 1320.36
29 91536890 3 2 6.473 1326.83
30 91536890 3 2 0.595 1327.43
Thanks
Scott