```Date: Wed, 10 Jul 1996 17:49:33 -0400 Reply-To: Chin-Lin Tseng Sender: "SAS(r) Discussion" From: Chin-Lin Tseng Subject: Q.s ABOUT ARRAY... Hi! Q1. is there any other smarter way to get the samy results as the following progrms do? > > array varmk varmk3 varmk5 varmk7 varmk11 varmk14 varmk19 varmk23 varmk27 > varmk31 varmk34 varmk37 varmk41; > do over varmk; > varmk=0; > end; > array mk3(5) mk3p01-mk3p05; > do k=1 to 5; > if mfocal1=mk3(k) then varmk3=1; > end; > > array mk5(5) mk5p01-mk5p05; > do k=1 to 5; > if mfocal1=mk5(k) then varmk5=1; > end; > array mk7(2) mk7p01 mk7p02; do i=to to 2; if mfocal1=mk7(2) then varmk7=1; array mk11(2) mk11p01 mk11p02; do i=to to 2; if mfocal1=mk11(2) then varmk11=1; array mk14(2) mk14p01 mk14p02; do i=to to 2; if mfocal1=mk14(2) then varmk14=1; array mk19(2) mk19p01 mk19p02; do i=to to 2; if mfocal1=mk19(2) then varmk19=1; array mk23(2) mk23p01 mk23p02; do i=to to 2; if mfocal1=mk23(2) then varmk23=1; array mk27(2) mk27p01 mk27p02; do i=to to 2; if mfocal1=mk27(2) then varmk27=1; array mk31(2) mk31p01 mk31p02; do i=to to 2; if mfocal1=mk31(2) then varmk31=1; array mk34(2) mk34p01 mk34p02; do i=to to 2; if mfocal1=mk34(2) then varmk34=1; array mk37(2) mk37p01 mk37p02; do i=to to 2; if mfocal1=mk37(2) then varmk37=1; array mk41(2) mk41p01 mk41p02; do i=to to 2; if mfocal1=mk41(2) then varmk41=1; > Q.2: With regard to Q.1, I wrote the followings, but there were error > messages saying , for example, "MK3 has already been defined,"...etc. > Where did I do wrong? > array varmk varmk3 varmk5 varmk7 varmk11 varmk14 varmk19 varmk23 varmk27 > varmk31 varmk34 varmk37 varmk41; > do over varmk; > varmk=0; > end; > array mk7(2) mk7p01-mk7p02; array mk11(2) mk11p01-mk11p02; array mk14(2) mk14p01 mk14p02; array mk19(2) mk19p01 mk19p02; array mk23(2) mk23p01 mk23p02; array mk27(2) mk27p01 mk27p02; array mk31(2) mk31p01 mk31p02; array mk34(2) mk34p01 mk34p02; array mk37(2) mk37p01 mk37p02; array mk41(2) mk47p01 mk41p02; array mk(12) mk3 mk5 mk7 mk11 mk14 mk19 mk23 mk27 mk31 mk34 mk37 mk41; > array mk3(5) mk3p01-mk3p05; > array mk5(5) mk5p01-mk5p05; > do i=1 to 2; > do j=1 to 5; > if mfocal1=mk(i) then varmk(i)=1; > end; > end; array mk(12) mk3 mk5 mk7 mk11 mk14 mk19 mk23 mk27 mk31 mk34 mk37 mk41; array mk7(2) mk7p01-mk7p02; array mk11(2) mk11p01-mk11p02; array mk14(2) mk14p01 mk14p02; array mk19(2) mk19p01 mk19p02; array mk23(2) mk23p01 mk23p02; array mk27(2) mk27p01 mk27p02; array mk31(2) mk31p01 mk31p02; array mk34(2) mk34p01 mk34p02; array mk37(2) mk37p01 mk37p02; array mk41(2) mk47p01 mk41p02; > do i=3 to 12; > do j=1 to 2; > if mfocal1=mk(i) then varmk(i)=1; > end; > end; > Thank you for your help! > Chin-Lin > > ```

Back to: Top of message | Previous page | Main SAS-L page