avatar
SAS coding help needed# DataSciences - 数据科学
y*3
1
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
avatar
s*h
2
搜一下lag的用法。
加点私货:用SAS这种语言来做超过简单proc的东西就是反人类。
avatar
C*e
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

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。