GCLAS

Gets the unique values of each classification variable.

Required Arguments

XNROW by NCOL matrix containing the data. (Input)

INDCL — Index vector of length NCLVAR containing the column numbers of X that are the classification variables. (Input)

MAXCL — An upper bound on the sum of the number of distinct values taken on by each classification variable. (Input)

NCLVAL — Vector of length NCLVAR containing the number of values taken on by each classification variable. (Output, if IDO = 0 or IDO = 1; input/output, if IDO = 2 or IDO = 3) NCLVAL(I) is the number of distinct values for the I-th classification variable.

CLVAL — Vector of length NCLVAL(1) + NCLVAL(2) +  + NCLVAL(NCLVAR) containing the values of the classification variables. (Output, if IDO = 0 or IDO = 1; Input/Output, if IDO = 2 or IDO = 3)
Since in general the length of CLVAL will not be known in advance, MAXCL (an upper bound for this length) should be used for purposes of dimensioning CLVAL. The first NCLVAL(1) variables contain the values of the first classification variable; the next NCLVAL(2) variables contain the values of the second classification variable; and so on. The last NCLVAL(NCLVAR) variables contain the values of the last classification variable. After invocation of GCLAS with IDO = 3, CLVAL contains the values sorted in ascending order by the classification variable.

Optional Arguments

IDO — Processing option. (Input)
Default: IDO = 0.

 

IDO

Action

0

This is the only invocation of GCLAS for this data set, and all the data are input at once.

1

This is the first invocation, and additional calls to GCLAS will be made. Unique values for the classification variables are retrieved from X.

2

This is an intermediate invocation of GCLAS. Unique values for the classification variables are retrieved from X.

3

This is the final invocation of GCLAS. Unique values for the classification variables are retrieved from X, and the values in CLVAL are sorted in ascending order for each classification variable.

NROW — Number of rows of data in X. (Input)
Default: NROW = size (X,1).

NCOL — Number of columns in X. (Input)
Default: NCOL = size (X,2).

LDX — Leading dimension of X exactly as specified in the dimension statement in the calling program. (Input)
Default: LDX = size (X,1).

NCLVAR — Number of classification variables. (Input)
Default: NCLVAR = size (INDCL,1).

NMISS — Vector of length NCLVAR containing the number of elements of the data containing NaN for any classification variable. (Output, if IDO = 0 or IDO = 1; input/output if IDO = 2 or IDO = 3)

FORTRAN 90 Interface

Generic: CALL GCLAS (X, INDCL, MAXCL, NCLVAL, CLVAL [])

Specific: The specific interface names are S_GCLAS and D_GCLAS.

FORTRAN 77 Interface

Single: CALL GCLAS (IDO, NROW, NCOL, X, LDX, NCLVAR, INDCL, MAXCL, NCLVAL, CLVAL, NMISS)

Double: The double precision name is DGCLAS.

Description

Routine GCLAS gets the unique values of m (Input in NCLVAR) classification variables. The routine can be used in conjunction with routine GRGLM. Routine GRGLM requires the values of the classification variables output by GCLAS in order to generate dummy variables for the general linear model.

In the input array X, missing values for a classification variable can be indicated by NaN (not a number). NAN is represented by AMACH(6). (See the section Machine-Dependent Constants in the Reference Material for a further discussion of AMACH, and missing values.) The nonmissing values of the classifications variables are output in CLVAL. If for a particular row of X a value of a classification variable is missing, nonmissing values of the other classification variables are still used. The number of elements equal to NaN for each classification variable is output in NMISS.

Comments

Informational Error

 

Type

Code

Description

4

1

MAXCL is too small. Increase MAXCL and the dimension of CLVAL.

Example

In the following example, the unique values of two classification variables are obtained from a data set XX with six rows. Here, routine GCLAS is invoked repeatedly with one row of the data set input into X at a time. Initially, GCLAS is invoked with IDO = 1, then with IDO = 2 for each of the six rows of data, and finally with IDO = 3.

 

USE GCLAS_INT

USE SCOPY_INT

USE WRRRL_INT

USE WRIRL_INT

 

IMPLICIT NONE

INTEGER LDX, LDXX, MAXCL, NCLVAR, NCOL, NOBS, J

PARAMETER (LDX=1, MAXCL=5, NCLVAR=2, NCOL=2, NOBS=6, LDXX=NOBS)

!

INTEGER I, IDO, INDCL(NCLVAR), NCLVAL(NCLVAR), NMISS(NCLVAR), &

NROW

REAL CLVAL(MAXCL), X(LDX,NCOL), XX(LDXX,NCOL)

CHARACTER CLABEL(2)*8, RLABEL(1)*17

!

DATA INDCL/1, 2/, NCLVAL/2, 3/

DATA (XX(1,J),J=1,NCOL)/10.0, 5.0/

DATA (XX(2,J),J=1,NCOL)/20.0, 15.0/

DATA (XX(3,J),J=1,NCOL)/20.0, 10.0/

DATA (XX(4,J),J=1,NCOL)/10.0, 10.0/

DATA (XX(5,J),J=1,NCOL)/10.0, 15.0/

DATA (XX(6,J),J=1,NCOL)/20.0, 5.0/

!

IDO = 1

NROW = 0

CALL GCLAS (X, INDCL, MAXCL, NCLVAL, CLVAL, IDO=IDO, NROW=NROW, &

NMISS=NMISS)

IDO = 2

NROW = 1

DO 10 I=1, NOBS

CALL SCOPY (NCOL, XX(I:,1), LDXX, X(1:,1), LDX)

CALL GCLAS (X, INDCL, MAXCL, NCLVAL, CLVAL, IDO=IDO, NROW=NROW, &

NMISS=NMISS)

10 CONTINUE

IDO = 3

NROW = 0

CALL GCLAS (X, INDCL, MAXCL, NCLVAL, CLVAL, IDO=IDO, &

NROW=NROW, NMISS=NMISS)

I = 1

RLABEL(1) = 'Variable CLVAL:'

CLABEL(1) = 'None'

DO 20 J=1, NCLVAR

WRITE (RLABEL(1)(9:10),'(I2)') J

CALL WRRRL (' ', CLVAL(I:), RLABEL, CLABEL, 1, NCLVAL(J), 1)

I = I + NCLVAL(J)

20 CONTINUE

RLABEL(1) = 'NUMBER'

CLABEL(1) = 'Variable'

CLABEL(2) = 'NMISS'

CALL WRIRL ('%/', NMISS, RLABEL, CLABEL)

END

Output

 

Variable 1 CLVAL: 10.00 20.00

Variable 2 CLVAL: 5.00 10.00 15.00

 

Variable NMISS

1 0

2 0