ATTRC Function


ATTRC Function

Returns the value of a character attribute for a SAS data set

Category: SAS File I/O

Syntax

ATTRC ( data-set-id , attr- name )

Arguments

data-set-id

  • specifies the data set identifier that the OPEN function returns.

attr-name

  • is an attribute name. If attr-name is invalid, a missing value is returned.

    Valid values for use with attr-name are:

CHARSET

  • returns a value for the character set of the machine 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

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 data 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, such as:

    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 data 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 machine 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

  • This example generates a message if the SAS data set has not been opened in INPUT SEQUENTIAL mode. The message is written to the SAS log as follows :

     %let mode=%sysfunc(attrc(&dsid,MODE));  %if &mode ne IS %then     %put Data set has not been opened in INPUT SEQUENTIAL mode.; 
  • This example tests whether a data set has been sorted and writes the result to the SAS log.

     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; 

See Also

Functions:

  • 'ATTRN Function' on page 324

  • 'OPEN Function' on page 690




SAS 9.1 Language Reference Dictionary, Volumes 1, 2 and 3
SAS 9.1 Language Reference Dictionary, Volumes 1, 2 and 3
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 704

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net