I use retain statement but I realize sometimes it affects values of variabels in a strange way. I plan to
stay away from using RETAIN statement altogether.
This is a data step with RETAIN statement. Notice that the results of FREQ show abnomality of values. F1club
and F1S42 are supposed to be roughly the same, but they are not--as a result of using RETAIN statement.
data deta.covariate1;
retain F1club F1S42 ;
set X1;
keep F1club F1S42;
if
F1s42 > -1 and F1s42 < 8 then do;
F1club=F1S42;
end;
run;
proc freq data=deta.covariate1;
tables F1club F1S42;
run;
The FREQ Procedure
Cumulative Cumulative
F1club Frequency Percent Frequency
Percent
ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ
0 10681 38.99
10681 38.99
1 4523 16.51
15204 55.50
2 5454 19.91
20658 75.41
3 3141 11.47
23799 86.88
4 3095 11.30
26894 98.17
5 500 1.83
27394 100.00
TIME SPENT ON EXTRACURRICULAR ACTIVITIES
Cumulative Cumulative
F1S42 Frequency Percent Frequency
Percent
ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ
0 6798 36.79
6798 36.79
1 3048 16.49
9846 53.28
2 3588 19.42
13434 72.70
3 2152 11.65
15586 84.34
4 2107 11.40
17693 95.75
5 348 1.88
18041 97.63
96 5 0.03
18046 97.66
98 433 2.34
18479 100.00
Frequency Missing = 8915