NAG Library Manual, Mark 29.3
```    Program g03aafe

!     G03AAF Example Program Text

!     Mark 29.3 Release. NAG Copyright 2023.

!     .. Use Statements ..
Use nag_library, Only: g03aaf, nag_wp, x04caf
!     .. Implicit None Statement ..
Implicit None
!     .. Parameters ..
Integer, Parameter               :: nin = 5, nout = 6
!     .. Local Scalars ..
Integer                          :: i, ifail, lde, ldp, ldv, ldx, lwt,   &
m, n, nvar
Logical                          :: verbose
Character (1)                    :: matrix, std, weight
!     .. Local Arrays ..
Real (Kind=nag_wp), Allocatable  :: e(:,:), p(:,:), s(:), v(:,:), wk(:), &
wt(:), x(:,:)
Integer, Allocatable             :: isx(:)
!     .. Intrinsic Procedures ..
Intrinsic                        :: count
!     .. Executable Statements ..
Write (nout,*) 'G03AAF Example Program Results'
Write (nout,*)

!     Skip heading in data file

!     Read in the problem size
Read (nin,*) matrix, std, weight, n, m

If (weight=='W' .Or. weight=='w') Then
lwt = n
Else
lwt = 0
End If
ldx = n
Allocate (x(ldx,m),wt(lwt),isx(m),s(m))

If (lwt>0) Then
Else
End If

!     Read in variable inclusion flags

If (matrix=='S' .Or. matrix=='s') Then
End If

!     Calculate NVAR
nvar = count(isx(1:m)==1)

lde = nvar
ldp = nvar
ldv = n
Allocate (e(lde,6),p(ldp,nvar),v(ldv,nvar),wk(1))

!     Perform PCA
ifail = 0
Call g03aaf(matrix,std,weight,n,m,x,ldx,isx,s,wt,nvar,e,lde,p,ldp,v,ldv, &
wk,ifail)

!     Display results
Write (nout,*)                                                           &
'Eigenvalues  Percentage  Cumulative     Chisq      DF     Sig'
Write (nout,*) '              variation   variation'
Write (nout,*)
Write (nout,99999)(e(i,1:6),i=1,nvar)

!     Set verbose to .True. to see principal component loadings and scores
verbose = .False.
If (verbose) Then
Write (nout,*)
Flush (nout)
ifail = 0
Call x04caf('General',' ',nvar,nvar,p,ldp,                             &