boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Statistics版 - SAS code help needed: multiple do loops do not return what is expected
相关主题
急问一个SAS 的常见问题
SAS问题请教
SAS问题再请教
SAS help : get macro variables as an string but not character variable.
请教sas code问题
overall mean in sas for several variables
请问怎么样用SAS生成这样一个变量?
如何用SAS 生成一个组合变量?
【包子】R 时间变量做减法
do loop 的一道题
相关话题的讨论汇总
话题: else话题: temp话题: 103话题: do话题: end
进入Statistics版参与讨论
1 (共1页)
s**********l
发帖数: 395
1
Sorry, I cannot type in Chinese now.
Hi All,
I need to use the combination conditions of two variables: temp1 or temp2
and another eight variables: c01-c08 to define the value of r1 and r2.
However, I did not get what I wanted.
The data and the results should be like this(only selected several variables
):
C08 C05 C07 C02 temp1 temp2 r1 r2
1385 6 4 74 0.8 0.2 60 103
445 4 5 91 0.2 0.7 103 103
170 15 5 67 0.1 0.5 12 57
151 3 4 26 0.1 0.3 12 67
549 3 3 71 0.2 0.8 103 2
138 17 3 36 0.5 0.4 57 57
611 7 5 53 0.7 0.8 103 2
456 5 4 60 0.1 0.2 12 103
525 5 3 61 0.1 0.2 12 103
2390 13 6 56 0.1 0.5 12 57
But what some of r2 values I got are missing.
Below is my SAS code. Anyone knows how to change the code to generate the
correct results? Thank you so much.
data temp2;
set temp1;
array temp {2} temp1-temp2;;
array r{2} r1-r2;
do i=1 to 2;
if temp{i}=0.1 then do;
if C01>=0 then r{i}=12;
else r{i}=33;
end;
if temp{i}=0.2 then do;
if C02 in (.B,.D,.G) then r{i}=27;
else if C02 >=0 then r{i}=103;
else r{i}=109;
end;
if temp{i}=0.3 then do;
if C03=.C then r{i}=27;
else if C03 =.E then r{i}=.;
else if C03>=1 then r{i}=67;
else r{i}=2;
end;
if temp{i}=0.4 then do;
if C04>=0 then r{i}=39;
else r{i}=33;
end;
if temp{i}=0.5 then do;
if C05 =.A then r{i}=.;
else if C05>=0 then r{i}=57;
else r{i}=2;
end;
if temp{i}=0.6 then do;
if C06>=0 then r{i}=2;
else r{i}=109;
end;
if temp{i}=0.7 then do;
if C07 in (.C,.D) then r{i}=27;
else if C07>=0 then r{i}=103;
else r{i}=2;
end;
if temp{i}=0.8 then do;
if C08=.B then r{i}=27;
else if C08>=0 then r{i}=60;
else r{i}=109;
end;
end;
drop i;
run;
proc print data=temp2;run;
s**********l
发帖数: 395
2
没人知道吗?
1 (共1页)
进入Statistics版参与讨论
相关主题
do loop 的一道题
Ask a SAS question
SAS里面怎么设置vector
A quick question about masking in macro
请教sas adv 130题中 第12题 第19题
Help on a SAS question
急问,在线等:SAS adv certification Question about SELECT v.s IF/THEN ELSE
问个sas问题
弱问一个data clean的问题,求各位指点。
SAS code help!! thanks
相关话题的讨论汇总
话题: else话题: temp话题: 103话题: do话题: end