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 | |
|