C
C     ..................................................................
C
C        SUBROUTINE SUBMX
C
C        PURPOSE
C           BASED ON VECTOR S DERIVED FROM SUBROUTINE SUBST OR ABSNT,
C           THIS SUBROUTINE COPIES FROM A LARGER MATRIX OF OBSERVATION
C           DATA A SUBSET MATRIX OF THOSE OBSERVATIONS WHICH HAVE
C           SATISFIED CERTAIN CONDITION.  THIS SUBROUTINE IS NORMALLY
C           USED PRIOR TO STATISTICAL ANALYSES (E.G., MULTIPLE REGRES-
C           SION, FACTOR ANALYSIS).
C
C        USAGE
C           CALL SUBMX (A,D,S,NO,NV,N)
C
C        DESCRIPTION OF PARAMETERS
C           A  - INPUT MATRIX OF OBSERVATIONS, NO BY NV.
C           D  - OUTPUT MATRIX OF OBSERVATIONS, N BY NV.
C           S -  INPUT VECTOR OF LENGTH NO CONTAINING THE CODES DERIVED
C                FROM SUBROUTINE SUBST OR ABSNT.
C           NO - NUMBER OF OBSERVATIONS. NO MUST BE > OR = TO 1.
C           NV - NUMBER OF VARIABLES. NV MUST BE > OR = TO 1.
C           N  - OUTPUT VARIABLE CONTAINING THE NUMBER OF NON-ZERO CODES
C                IN VECTOR S.
C
C        REMARKS
C           MATRIX D CAN BE IN THE SAME LOCATION AS MATRIX A.
C
C        SUBROUTINES AND FUNCTION SUBPROGRAMS REQUIRED
C           NONE
C
C        METHOD
C           IF S(I) CONTAINS A NON-ZERO CODE, I-TH OBSERVATION IS
C           COPIED FROM THE INPUT MATRIX TO THE OUTPUT MATRIX.
C
C     ..................................................................
C
      SUBROUTINE SUBMX (A,D,S,NO,NV,N)
      DIMENSION A(1),D(1),S(1)
C
      L=0
      LL=0
      DO 20 J=1,NV
      DO 15 I=1,NO
      L=L+1
      IF(S(I)) 15, 15, 10
   10 LL=LL+1
      D(LL)=A(L)
   15 CONTINUE
   20 CONTINUE
C
C        COUNT NON-ZERO CODES IN VECTOR S
C
      N=0
      DO 30 I=1,NO
      IF(S(I)) 30, 30, 25
   25 N=N+1
   30 CONTINUE
C
      RETURN
      END
