ATTRN Function

Returns the value of a numeric attribute for a SAS data set.

Category:SAS File I/O
Restriction:This function is not valid on the CAS server.

Syntax

Required Arguments

data-set-id

specifies the data set identifier that the OPEN function returns.

attribute-name

is the name of the SAS data set attribute whose numeric value is returned. If the value of attribute-name is invalid, a missing value is returned. Here is a list of SAS data set attribute names and their values:

ALTERPW

specifies whether a password is required to alter the data set.

1the data set is Alter protected.
0the data set is not Alter protected.

ANOBS

specifies whether the engine knows the number of observations.

1the engine knows the number of observations.
0the engine does not know the number of observations.

ANY

specifies whether the data set has observations or variables.

−1the data set has no observations or variables.
0the data set has no observations.
1the data set has observations and variables.
AliasVAROBS

ARAND

specifies whether the engine supports random access.

1the engine supports random access.
0the engine does not support random access.
AliasRANDOM

ARWU

specifies whether the engine can manipulate files.

1the engine is not read-only. It can create or update SAS files.
0the engine is read-only.

AUDIT

specifies whether logging to an audit file is enabled.

1logging is enabled.
0logging is suspended.

AUDIT_DATA

specifies whether after-update record images are stored.

1after-update record images are stored.
0after-update record images are not stored.

AUDIT_BEFORE

specifies whether before-update record images are stored.

1before-update record images are stored.
0before-update record images are not stored.

AUDIT_ERROR

specifies whether unsuccessful after-update record images are stored.

1unsuccessful after-update record images are stored.
0unsuccessful after-update record images are not stored.

CRDTE

specifies the date on which the data set was created. The value that is returned is the internal SAS datetime value for the creation date.

TipUse the DATETIME. format to display this value.

ICONST

returns information about the existence of integrity constraints for a SAS data set.

0no integrity constraints.
1one or more general integrity constraints.
2one or more referential integrity constraints.
3both one or more general integrity constraints and one or more referential integrity constraints.

INDEX

specifies whether the data set supports indexing.

1indexing is supported.
0indexing is not supported.

ISINDEX

specifies whether the data set is indexed.

1at least one index exists for the data set.
0the data set is not indexed.

ISSUBSET

specifies whether the data set is a subset.

1at least one WHERE clause is active.
0no WHERE clause is active.

LRECL

specifies the logical record length.

LRID

specifies the length of the record ID.

MAXGEN

specifies the maximum number of generations.

MAXRC

specifies whether an application checks return codes.

1an application checks return codes.
0an application does not check return codes.

MODTE

specifies the last date and time that the data set was modified. The value returned is the internal SAS datetime value.

TipUse the DATETIME. format to display this value.

NDEL

specifies the number of observations in the data set that are marked for deletion.

NEXTGEN

specifies the next generation number to generate.

NLOBS

specifies the number of logical observations (the observations that are not marked for deletion). An active WHERE clause does not affect this number.

−1the number of observations is not available.

NLOBSF

specifies the number of logical observations (the observations that are not marked for deletion) by forcing each observation to be read and by taking the FIRSTOBS system option, the OBS system option, and the WHERE clauses into account.

TipPassing NLOBSF to ATTRN requires the engine to read every observation from the data set that matches the WHERE clause. Based on the file type and file size, reading these observations can be a time-consuming process.

NOBS

specifies the number of physical observations (including the observations that are marked for deletion). An active WHERE clause does not affect this number.

−1the number of observations is not available.

NVARS

specifies the number of variables in the data set.

PW

specifies whether a password is required to access the data set.

1the data set is protected.
0the data set is not protected.

RADIX

specifies whether access by observation number (radix addressability) is allowed.

1access by observation number is allowed.
0access by observation number is not allowed.
Note: A data set that is accessed by a tape engine is index addressable although it cannot be accessed by an observation number.

READPW

specifies whether a password is required to read the data set.

1the data set is Read protected.
0the data set is not Read protected.

REUSE

specifies whether new observations can be written to free space in compressed SAS data sets.

1free space can be reused.
0free space cannot be reused.

TAPE

specifies the status of the data set tape.

1the data set is a sequential file.
0the data set is not a sequential file.

WHSTMT

specifies the active WHERE clauses.

0no WHERE clause is active.
1a permanent WHERE clause is active.
2a temporary WHERE clause is active.
3both permanent and temporary WHERE clauses are active.

WRITEPW

specifies whether a password is required to write to the data set.

1the data set is Write protected.
0the data set is not Write protected.

Examples

Example 1: Checking for an Active WHERE Clause

This example checks whether a WHERE clause is currently active for a data set.
%let iswhere=%sysfunc(attrn(&dsid,whstmt));
%if &iswhere %then
   %put A WHERE clause is currently active.;

Example 2: Checking for an Indexed Data Set

This example checks whether a data set is indexed.
data _null_;
   dsid=open("mydata");
   isindex=attrn(dsid, "isindex");
   if isindex then put "data set is indexed";
   else put "data set is not indexed";
run;

Example 3: Checking a Data Set for Password Protection

This example checks whether a data set is protected with a password.
data _null_;
   dsid=open("mydata");
   pw=attrn(dsid, "pw");
   if pw then put "data set is protected";
run;

See Also

Last updated: March 16, 2017