What i want is an if-else if (i won't need an else statement for this problem) structure so that if a statement or set of statements within an if/else if is executed the rest of the structure is not executed. in the log output everything seems to go ok until the fifth else if block where for unknown to me reasons an if-then is expected. If i take out the 'else's, it will run but isn't that equivalent to a set of if-then statements, all of which are executed? (also, you'll see a vdu{1} referenced. That is defined above this block of syntax and i do not believe is the problem). 625 array voderr(12) ODERR1-ODERR12; 626 if (A3ODRG90 eq 1 or A3ODRG90 eq .p) then 627 do i=1 to 12; 628 voderr{i}=0; 629 nval=0; 630 k=(i-1)*9; 631 do j=1 to 7; 632 if (vdu{k+j} eq 1) then nval=sum(of nval,1); 633 end; 634 * j=8 IS DNU, j=9 IS PNA; 635 * possible cases; 636 * nval=0, DNU=1, PNA=. no error. A3ODxxW1-A3ODxxW7=0, A3ODxxW9=0; 637 if (nval eq 0 and vdu{k+8} eq 1 and vdu{k+9} eq .) then do; 638 do j=1 to 7; 639 vdu{k+j}=0; 640 end; 641 vdu{k+9}=0; 642 voderr{i}=0; 643 end; 644 * nval=0, DNU=., PNA=1 no error. A3ODxxW1-A3ODxxW7=.p, A3ODxxW8=0; 645 else if (nval eq 0 and vdu{k+8} eq . and vdu{k+9} eq 1) then do; 646 do j=1 to 7; 647 vdu{k+j}=.p; 648 end; 649 vdu{k+8}=0; 650 voderr{i}=0; 651 end; 652 * nval=0, DNU=., PNA=. no error. A3ODxxW1-A3ODxxW9=.p; 653 else if (nval eq 0 and vdu{k+8} eq . and vdu{k+9} eq .) then do; 654 do j=1 to 7; 655 vdu{k+j}=.p; 656 end; 657 vdu{k+8}=0; 658 vdu{k+9}=0; 659 voderr{i}=0; 660 end; 661 * nval>0, DNU=., PNA=. no error. A3ODxxW1-A3ODxxW9: recode . to 0; 662 else if (nval gt 0 and vdu{k+8} eq . and vdu{k+9} eq .) then do; 663 do j=1 to 7; 664 if (vdu{k+j} ne 1) then vdu{k+j}=0; 665 end; 666 vdu{k+8}=0; 667 vdu{k+9}=0; 668 voderr{i}=0; 669 end; 670 * nval=0, DNU=1, PNA=1 error. do what? TYPE 1 ERROR; 671 else if (nval eq 0 and vdu{k+8} eq 1 and vdu{k+9} eq 1) 672 then voderr{i}=1; /* ERROR TYPE 1: e.g., 000000011 */; 673 * nval>0, DNU=1, PNA=. error. do what? TYPE 2 ERROR; 674 else if (nval ge 1 and vdu{k+8} eq 1 and vdu{k+9} eq .) ---- 160 ERROR 160-185: No matching IF-THEN clause. 675 then voderr{i}=2; /* ERROR TYPE 2: e.g., 10000001. */; 676 * nval>0, DNU=., PNA=1 error. do what? TYPE 3 ERROR; 677 else if (nval ge 1 and vdu{k+8} eq . and vdu{k++9} eq 1) ---- 160 ERROR 160-185: No matching IF-THEN clause. 678 then voderr{i}=3; /* ERROR TYPE 3: e.g., 1000000.1 */; 679 * nval>0, DNU=1, PNA=1 error. do what? TYPE 4 ERROR; 680 else if (nval ge 1 and vdu{k+8} eq 1 and vdu{k++9} eq 1) ---- 160 ERROR 160-185: No matching IF-THEN clause. 681 then voderr{i}=4; /* ERROR TYPE 4: e.g., 100000011 */; 682 end; 683 ANYODERR=sum(of ODERR1-ODERR12); 684 run;
... View more