1. Home
  2. GETATTRIBUTE directive

GETATTRIBUTE directive

Accesses attributes of structures.

Option

ATTRIBUTE = string tokens Which attributes to access (nvalues, nlevels, nrows, ncolumns, type {type number}, levels, labels {of a factor or pointer}, nmv, present, identifier, refnumber {structure number}, extra, decimals, characters, minimum, maximum, restriction, mode {integer code 1 – 5 denoting type of values: double real, real, integer, character and word}, maxline {of a text or factor}, rows, columns, classification, margins {of a table}, associatedidentifier {of a table}, unknown {cell of a table}, suffixes {of a pointer}, owner, terms {of an SSPM}, groups {of an SSPM}, weights {of an SSPM}, SSPMauxiliary, SSPrst, tsmmodel, rstat {of an RSAVE}, stype {type as a character string}, reference level {of a factor}, drepresentation, unitlevels {of a vector}, iprint, datavariate {of a table}, summarytype {of a table}, percentquantile {of a table of quantiles}, %margin {of a table of percentages} coding {of a text}); default * i.e. none

Parameters

STRUCTURE = identifiers Structures whose attributes are to be accessed
SAVE = pointers Pointer to store copies of the attributes of each structure; these are labelled by the ATTRIBUTE strings

Description

The GETATTRIBUTE directive lets you access attributes of each of the structures that are listed with its STRUCTURE parameter. It refers to the list of structures by pointers, which are set up by the SAVE parameter. You must always set the option and both parameters.

If you request an attribute that is not relevant to a structure, it is omitted from the pointer. Thus for example the nlevels, levels and labels settings are relevant only for factors, and nrows and ncolumns only for matrices. The references to those attributes that you do specify are always stored in the order shown in the definition of the ATTRIBUTE option at the beginning of this subsection.

For attributes that are single numbers, the information is copied into an unnamed scalar which is pointed to by the appropriate element of the pointer; if the attribute has not been set, then the corresponding scalar will contains a missing value. For the attributes stype, identifier, iprint, margins, associatedidentifier, summarytype and tsmodel, the corresponding element of the pointer is a text structure containing a single line. For the other attributes, the corresponding element of the pointer stores a reference to the attribute itself. One example is the labels vector of a factor. However, if the factor has no labels vector the corresponding entry of the pointer is set to the missing value.

The type setting gives a scalar value indicating the type of structure, by the code:

1 scalar
2 factor
3 text
4 variate
5 matrix
6 diagonal matrix
7 symmetric matrix
8 table
9 ASAVE
10 TSAVE
11 expression
12 formula
13 dummy
14 pointer
15 LRV
16 SSPM
17 TSM
18 RSAVE
22 tree
32 VSAVE

Alternatively, the stype setting supplies the type name in a text structure. This works not only for the standard Genstat types, such as variates and factors, but also for user-defined types (see STRUCTURE).

Option: ATTRIBUTE.
Parameters: STRUCTURE, SAVE.

See also

Directives: SCALAR, VARIATE, TEXT, FACTOR, MATRIX, SYMMETRICMATRIX, DIAGONALMATRIX, TABLE, DUMMY, POINTER, EXPRESSION, FORMULA, LRV, SSPM, TREE, TSM.

Commands for: Data structures.

Example

" Examples 1:2.11.3a-c "
VARIATE [VALUES=1,2,*,4] X
GETATTRIBUTE [ATTRIBUTE=nvalues,nmv] X; P
PRINT P[]
VARIATE [VALUES=4,8,12] Lev
FACTOR [LEVELS=Lev] F
GETATTRIBUTE [ATTRIBUTE=levels,labels] F; P
DUMP [PRINT=attributes,values] P,Lev
STRUCTURE [NAME='complex number'] 'real','imaginary'; TYPE='scalar'
DECLARE      [TYPE='complex number'] C; VALUES=!p(3,2)
FACTOR       F
TEXT         T
VARIATE      V
GETATTRIBUTE [ATTRIBUTE=stype] C,F,T,V; SAVE=Typec,Typef,Typet,Typev
PRINT        Typec[],Typef[],Typet[],Typev[]
Updated on September 2, 2019

Was this article helpful?