各位朋友,我现在又个问题:
原数据程序为:
data a;
input id name$ score;
datalines;
1 chinese 20
1 math 90
1 politics 89
2 chinese 30
2 math 30
2 politics 77
3 chinese 30
3 math 40
3 politics 70
;
run;
用proc print 后可以得到: Obs id name score
1 1 chinese 20
2 1 math 90
3 1 politics 89
4 2 chinese 30
5 2 math 30
6 2 politics 77
7 3 chinese 30
8 3 math 40
9 3 politics 70
我的问题是如何给每个id 添加一个新的观测ratio,
ratio计算是相应id的chinese 对应的score除以politics对应的score。比如对于id=1,ratio=20/89;对于id=2,ratio=30/77,如此下去。这个程序当如何实现呢?如果先转置的话会很麻烦,有没有简单的方法呢?谢谢哟。