help needed from sas expert!
I have 2 variables in my sas data set-var1 var2. var2 only has value at the
first record.i need to compute the rest of var2 based on the ratios of two
records next to each other; for ex;
the 2nd row ; var22=(95/87)*85; then compute var23 based on the new number
and var12 and var13.
how to code this in sas efficiently? thanks
var1 var2
87 95
85
78
75
65
56
34
s*********h 发帖数: 6288
2
搜一下lag的用法。
加点私货:用SAS这种语言来做超过简单proc的东西就是反人类。
C********e 发帖数: 6
3
用ARRAY
data calculation(drop=i);
array var1{7} var11-var17 (87 85 78 75 65 56 34);
array var2{7} var21-var27 (95 0 0 0 0 0 0 );
do i=1 to 6;
var2{i+1}=(var2{i}/var1{i})*var1{i+1};
end;
proc print noobs data=calculation;
title 'Data Set calculation';
run;
格式之类可以随意调整
the
【在 y**3 的大作中提到】 : help needed from sas expert! : I have 2 variables in my sas data set-var1 var2. var2 only has value at the : first record.i need to compute the rest of var2 based on the ratios of two : records next to each other; for ex; : the 2nd row ; var22=(95/87)*85; then compute var23 based on the new number : and var12 and var13. : how to code this in sas efficiently? thanks : var1 var2 : 87 95 : 85