ATTRC Function
Returns the value of a character 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 a SAS data set attribute. 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:
CHARSET
returns a value for the character set of the computer that created the data set.
| empty string | data set not sorted |
| ASCII | ASCII character set |
| EBCDIC | EBCDIC character set |
| ANSI | OS/2 ANSI standard ASCII character set |
| OEM | OS/2 OEM code format |
COMPRESS
returns a value that specifies how a data set is compressed.
| CHAR | specifies that the data set is compressed as character data. |
| BINARY | specifies that the data set is compressed as binary data. |
| NO | specifies that the data set is not compressed. |
DATAREP
returns a value that indicates whether the data set is in a native format.
| NATIVE | indicates that the data set is in native format. |
| FOREIGN | indicates that the data set is in a foreign format. |
ENCRYPT
returns 'YES' or 'NO' depending on whether the SAS data set is encrypted.
ENGINE
returns the name of the engine that is used to access the data set.
LABEL
returns the label assigned to the data set.
LIB
returns the libref of the SAS library in which the data set resides.
MEM
returns the SAS data set name.
MODE
returns the mode in which the SAS data set was opened:
| I | INPUT mode allows random access if the engine supports it. Otherwise, it defaults to IN mode. |
| IN | INPUT mode reads sequentially and allows revisiting observations. |
| IS | INPUT mode reads sequentially but does not allow revisiting observations. |
| N | NEW mode creates a new data set. |
| U | UPDATE mode allows random access if the engine supports it. Otherwise, it defaults to UN mode. |
| UN | UPDATE mode reads sequentially and allows revisiting observations. |
| US | UPDATE mode reads sequentially but does not allow revisiting observations. |
| V | UTILITY mode allows modification of variable attributes and indexes associated with the data set. |
MTYPE
returns the SAS library member type.
SORTEDBY
returns an empty string if the data set is not sorted. Otherwise, it returns the names of the BY variables in the standard BY statement format.
SORTLVL
returns a value that indicates how a data set was sorted:
| Empty string | Data set is not sorted. |
| WEAK | Sort order of the data set was established by the user (for example, through the SORTEDBY data set option). The system cannot validate its correctness, so the order of observations cannot be depended on. |
| STRONG | Sort order of the data set was established by the software (for example, through PROC SORT or the OUT= option in the CONTENTS procedure). |
SORTSEQ
returns an empty string if the data set is sorted on the native computer or if the sort collating sequence is the default for the operating environment. Otherwise, it returns the name of the alternate collating sequence used to sort the file.
TYPE
returns the SAS data set type.
Examples
Example 1: Writing a Message about Input Sequential Mode to the SAS Log
%let mode=%sysfunc(attrc(&dsid,MODE)); %if &mode ne IS %then %put Data set has not been opened in INPUT SEQUENTIAL mode.;
Example 2: Testing Whether a Data Set Has Been Sorted
data _null_;
dsid=open("sasdata.sortcars", "i");
charset=attrc(dsid, "CHARSET");
if charset = "" then
put "Data set has not been sorted.";
else put "Data set sorted with " charset
"character set.";
rc=close(dsid);
run;