我想问一个简短的问题。我想通过使用简单的样本我可以更好地解释。 所以,我有以下数据:
Time Value
13:45 0.2
13:45 0.4
13:45 0.3
13:46 0.1
13:46 0.2
13:46 0.3
13:46 0.5
13:46 0.4
我想再添加一列。此列中的值应为每分钟的标准偏差。所以,我想得到以下数据:
Time Value St.D
13:45 0.2 0.1 (it is the standard deviation of 0.2,0.4 and 0.3 - so st.dev for 13:45)
13:45 0.4 0.1
13:45 0.3 0.1
13:46 0.1 0.1528 (it is the standard deviation of 0.1,0.2,0.3,0.5 and 0.6 - so st.dev for 13:46)
13:46 0.2 0.1528
13:46 0.3 0.1528
13:46 0.5 0.1528
13:46 0.6 0.1528
非常感谢您的帮助。
答案 0 :(得分:0)
准备数据:
data a;
time ="13:45";
value=0.2;
output;
time ="13:45";
value=0.4;
output;
time ="13:45";
value=0.3;
output;
time ="13:46";
value=0.1;
output;
time ="13:46";
value=0.2;
output;
time ="13:46";
value=0.3;
output;
time ="13:46";
value=0.5;
output;
time ="13:46";
value=0.6;
output;
run;
计算stddev:
proc summary data=a stddev nonobs noprint nway;
by time;
var value;
output out=b(drop=_type_ _freq_) stddev()=;
run;
proc sql noprint;
CREATE TABLE res AS
SELECT a.*
,b.value as stddev
FROM a
LEFT JOIN b
ON a.time=b.time
;
quit;
然而,13:46的stddev与你的预期不同。此外,你在13:46([0.1,0.2,0.3,0.4,0.5],[0.1,0.2,0.3,0.5,0.6])的示例数据中有一点错字。