我有一个变量,即总和分数(“ fsum”),我需要为每个观察值计算加权的ridit分数,并将其另存为新变量,以允许我在其他分析中将ridits用作连续变量。
我尝试对proc freq语法使用out语句,但是当然它只是保存频率,而不是ridit分数(请参见下文)
proc freq data = ftest;
weight dataset_weight;
tables fsum / out = ridits scores = ridit;
run;
您可以使用ODS OUTPUT捕获RIDIT行分数。FREQ
TABLES
statement选项SCOROUT
告诉创建包含ODS表名的ODS OUTPUT的过程rowscores
。
此示例代码创建两个数据集work.freqdata
和work.riditscores
中,首先是从FREQ
TABLES
语句中,从其他的ODS OUTPUT
语句:
data have;
do id = 1 to 100;
do test = 1 to 6;
grade = 60 + ceil(40 * ranuni(123));
array ws (6) _temporary_ (0.15, 0.15, 0.10, 0.15, 0.10, 0.35);
W = ws(test);
output;
end;
end;
run;
ods noresults; * prevent actual ODS destination generation, but still create ODS output tables;
ods output rowscores=work.riditscores; * capture the desired ODS output table;
proc freq data=have;
weight W;
tables grade*test
/ scores=ridit
all
scorout
out=freqdata
;
run;
ods results;
不知道这是否是最明智的选择,但请换成一行,并命名为ridit_for_<score>
。
proc transpose data=riditscores out=ridit_across prefix=ridit_for_;
by table;
id grade;
var score;
run;
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句