1. Home
  2. FUNIQUEVALUES procedure

FUNIQUEVALUES procedure

Redefines a variate or text so that its values are unique (R.W. Payne).

Options

INCREMENT = scalar Increment to use to modify duplicated numbers; default * i.e. a suitable (small) value is determined automatically
ADDTO = string token Whether to add the increment to the value or the absolute value of duplicated numbers (value, absolutevalue); default abso

Parameters

OLDVECTOR = variates or texts Vectors whose values are to be made unique
NEWVECTOR = variates or texts New vectors with unique values; if unset, the values of the corresponding OLDVECTOR are replaced
CHANGED = scalars Indicates whether the values have changed

Description

FUNIQUEVALUES allows you to redefine a variate or a text so that its values become unique. The variates or texts are listed by the OLDVECTOR parameter, and the NEWVECTOR parameter can save new variates or texts with the redefined values. If no NEWVECTOR is defined for one of the variates or texts in the OLDVECTOR list, the new values are put into the original variate or text. The CHANGED parameter can save a scalar that set to one if the values were changed; otherwise it is set to zero.

FUNIQUEVALUES appends the characters '_1', _2' and so on to each duplicate value of a text. By default, with a variate, FUNIQUEVALUES adds a small increment to each zero or positive duplicate value, and subtracts that increment from each negative duplicate value. If you would prefer to add the increment to both positive and negative values, you can set option ADDTO=value. (This indicates that the increment is to be added to the value, rather than the absolute value of the duplicate number.) The default increment is taken as the largest power of 10 that is small enough to modify each duplicate value while preserving their numerical order. So, for example, if you had values 1, 2, 3, 2, 5 and 2, the increment would be 0.1; the second instance of 2 would become 2.1, and the third would become 2.2. As another example, if the values were 0.1, 0.2, 0.3, 0.2, 0,5 and 0.2, the increment would be 0.01; the second instance of 0.2 would then become 0.21, and the third would become 0.22. Alternatively, you can supply your own increment using the INCREMENT option.

Options: INCREMENT, ADDTO.

Parameters: OLDVECTOR, NEWVECTOR, CHANGED.

Action with RESTRICT

Any restrictions are ignored.

See also

Procedure: FACUNIQUE.

Commands for: Calculations and manipulation.

Example

CAPTION       'FACUNIQUEVALUES example'; STYLE=meta
VARIATE       [VALUES=2,5,2,3,6,8,5,9,5] v1
TEXT          [VALUES=b,e,b,c,f,h,e,i,e] t1
CALCULATE     v2 = v1 / 10
FUNIQUEVALUES v1,v2,t1; NEWVECTOR=nv1,nv2,nt1
PRINT         v1,nv1,v2,nv2,t1,nt1; FIELD=6; DECIMALS=2
FUNIQUEVALUES [INCREMENT=1] v2; NEWVECTOR=nv2
PRINT         v2,nv2; FIELD=6; DECIMALS=2
Updated on June 19, 2019

Was this article helpful?