1. Home
  2. VREPLACE procedure

VREPLACE procedure

Replaces values of vectors and pointers (R.W. Payne).

No options

Parameters

OLDSTRUCTURE = vectors or pointers Variate, factor, text or pointer whose values are to be replaced
NEWSTRUCTURE = vectors or pointers Variate, factor, text or pointer to store the new values; if unset these replace the values in the OLDSTRUCTURE
OLDVALUES = texts, variates or pointers Values to be replaced
NEWVALUES = texts, variates or pointers Replacement values

Description

VREPLACE replaces values in a variate, factor, text or pointer. For texts this differs from the TXREPLACE directive in that it replaces complete lines rather than strings of characters occurring anywhere within the text. It also takes account of restrictions.

The input variate, factor, text or pointer is supplied by the OLDSTRUCTURE parameter. The values to be replaced are specified by the OLDVALUES parameter, and the values to replace them are specified by the NEWVALUES parameter. For variates, texts or pointers, these should also be variates, texts or pointers. For factors, they can be either variates or texts. The NEWSTRUCTURE parameter can supply the identifier of a data structure to store the new values. If this is not set, they replace the values in the OLDSTRUCTURE.

Options: none.
Parameters: OLDSTRUCTURENEWSTRUCTUREOLDVALUESNEWVALUES.

Action with RESTRICT

VREPLACE takes account of restrictions on the OLDTEXT. Restrictions in the other parameters are ignored.

See also

Directives: EDIT, TXREPLACE.
Functions: REPLACE.
Commands for: Calculations and manipulation.

Example

CAPTION  'VREPLACE example'; STYLE=meta
TEXT     [VALUES=hh,a,a,b,b,d,d,e,e,f,f,g,g] t
VREPLACE t; NEWSTRUCTURE=nt; OLDVALUES=!t(a,b,c,d,e,f,g,h);\
         NEWVALUES=!t(H,G,F,E,D,C,B,A)
VARIATE [VALUES=8,1,1,2,2,4,4,5,5,6,6,7,7] v
VREPLACE v; NEWSTRUCTURE=nv; OLDVALUES=!(1,2,3,4,5,6,7,8);\
         NEWVALUES=!(8,7,6,5,4,3,2,1)
POINTER  [VALUES=hh,a,a,b,b,d,d,e,e,f,f,g,g] p
VREPLACE p; NEWSTRUCTURE=np; OLDVALUES=!p(a,b,c,d,e,f,g,h);\
         NEWVALUES=!p(H,G,F,E,D,C,B,A)
FACTOR   [LABELS=!t(a,b,c,d,e,f,g,hh); VALUES=8,1,1,2,2,4,4,5,5,6,6,7,7] f
VREPLACE f; NEWSTRUCTURE=nf; OLDVALUES=!t(a,b,c,d,e,f,g,hh,x,y,z);\
         NEWVALUES=!t(hh,g,f,e,d,c,b,a,z,y,x)
PRINT    t,nt,v,nv,p,np,f,nf; FIELD=6; DECIMALS=0
Updated on February 14, 2023

Was this article helpful?