/*SAS program that produces kinematic displays of knee motion during gait,
displayed at http://moon.ouhsc.edu/dthompso/pk/kneegraf.htm*/

DATA KNEE;
INPUT PERC KNEET2;
KNEET1=LAG1(KNEET2);
KNEE  =LAG2(KNEET2);
PERC=PERC-4;

/*Taylor series expansion, centered on variable KNEET1,
to obtain angular velocities and accelerations.
Equations are from Chaffin, D.B., Andersson, G.B.J., & Martin, B.J. (1999).
Occupational Biomechanics. 3rd ed. New York, Wiley. p. 142.*/
KNEEVEL=(KNEET2-KNEE)/(2*.02);
KNEEACC=(KNEET2+KNEE-(2*kneet1)) / (.02**2);
label kneet1='Knee angle during gait'
			kneevel='Angular velocity'
			kneeacc='Ang. acceleration'
			perc='Percentage of gait cycle';
IF PERC GE 0;

/*Data are from Winter, D.A. (1987). The Biomechanics and Motor Control of Human Gait. (1st ed.). 
Waterloo, Ontario: University of Waterloo.
*/
CARDS;
0  6.46
2 7.67
4  9.75
6   12.39
8   15.28
10   17.94
12   20
14   21.25
16  21.74
18  21.61
20  21
22  20.03
24  18.78
26  17.36
28  15.88
30  14.41
32  13.04
34  11.81
36  10.76
38  9.94
40  9.43
42  9.29
44  9.60
46  10.45
48  11.91
50  14.03
52  16.91
54  20.63
56  25.24
58  30.71
60  36.83
62  43.25
64  49.47
66  55.01
68  59.51
70  62.68
72  64.38
74  64.60
76  63.38
78  60.82
80  57
82  52.07
84  46.16
86  39.45
88  32.21
90  24.86
92  17.94
94  12.09
96  7.95
98  5.73
100  5.27
;

PROC  GPLOT data=knee;
 symbol v=plus i=join w=3;
 PLOT KNEEt1*PERC /  vaxis= 0 to 70 by 10 ;
 PLOT KNEEVEL*PERC / vaxis=-400 to 400 by 100 vref=0 ;
 PLOT KNEEACC*PERC / vref=0;
RUN;
quit;