嗨,我正在为暑期学校做一个项目,教书的人喜欢按排工作。我认为将其转换为矩阵并使用数组将是有益的。
当前数据集如下所示:
data longdata;
input var1 var2 Value;
datalines;
rowone colone 1
rowone coltwo 1
rowone colthree 2
rowone colfour 3
rowtwo colone 1
rowtwo coltwo 1
rowtwo colthree 1
rowtwo colfour 2
rowthree colone 3
rowthree coltwo 3
rowthree colthree 3
rowthree colfour 4
rowfour colone 1
rowfour coltwo 3
rowfour colthree 3
rowfour colfour 3
;
run;
我想把上面的变成这个,最好是通过一个 by 语句:
data matrixdata;
input var1-var4;
datalines;
colone coltwo colthree colfour
rowone 1 1 2 2
rowtwo 1 1 1 2
rowthree 3 3 3 4
rowfour 1 3 3 3
;
run;