REPORT abc.
DATA : BEGIN OF itab OCCURS 0,
num TYPE i,
END OF itab.
data : std type p decimals 2.
*-------------------------------------------------
itab-num = 8. APPEND itab.
itab-num = 25. APPEND itab.
itab-num = 7. APPEND itab.
itab-num = 5. APPEND itab.
itab-num = 8. APPEND itab.
itab-num = 3. APPEND itab.
itab-num = 10. APPEND itab.
itab-num = 12. APPEND itab.
itab-num = 9. APPEND itab.
DATA : BEGIN OF itab OCCURS 0,
num TYPE i,
END OF itab.
data : std type p decimals 2.
*-------------------------------------------------
itab-num = 8. APPEND itab.
itab-num = 25. APPEND itab.
itab-num = 7. APPEND itab.
itab-num = 5. APPEND itab.
itab-num = 8. APPEND itab.
itab-num = 3. APPEND itab.
itab-num = 10. APPEND itab.
itab-num = 12. APPEND itab.
itab-num = 9. APPEND itab.
PERFORM stdev changing std..
write :/ std.
*-------------------------------------------------
*-------------------------------------------------
*
*-------------------------------------------------
FORM stdev CHANGING std.
DATA : mn TYPE p DECIMALS 2.
DATA : sm TYPE i.
DATA : sm2 TYPE i.
DATA : dev TYPE p DECIMALS 2.
DATA : cnt TYPE i.
LOOP AT itab.
sm = sm + itab-num.
cnt = cnt + 1.
sm2 = sm2 + ( itab-num * itab-num ).
ENDLOOP.
mn = sm / cnt.
dev = ( sm2 - ( ( ( sm * sm ) / cnt ) ) ) / ( cnt - 1 ) .
dev = SQRT( dev ).
std = dev.
ENDFORM. "stdev