Syntax: DATASETS Procedure


Tip: Supports RUN- group processing.

Tip: Supports the Output Delivery System. See Output Delivery System on page 32 for details.

ODS Table Names : See: ODS Table Names on page 365

Reminder: See Chapter 3, Statements with the Same Function in Multiple Procedures, on page 57 for details. You can also use any global statements. See Global Statements on page 18 for a list.

See: DATASETS Procedure in the documentation for your operating environment.

PROC DATASETS < option(s) >;

  • AGE current- name related -SAS-file(s)

    • </ <ALTER= alter-password >

      <MEMTYPE= mtype >>;

  • APPEND BASE=< libref. > SAS-data-set

    • <APPENDVER=V6>

      <DATA=< libref. > SAS-data-set >

      <FORCE>;

  • AUDIT SAS-file <( SAS-password )>;

    • INITIATE

      • <AUDIT_ALL=NOYES>;

        • <LOG <ADMIN_IMAGE=YESNO>

          <BEFORE_IMAGE=YESNO>

          <DATA_IMAGE=YESNO>

          <ERROR_IMAGE=YESNO>>;

          <USER_VAR variable-1 < variable-n >>;

  • AUDIT SAS-file <(< SAS-password > <GENNUM= integer >)>;

    • SUSPENDRESUMETERMINATE;

  • CHANGE old-name-1=new-name-1

    • < old-name-n=new-name-n >

      </ <ALTER= alter-password >

      <GENNUM=ALL integer >

      <MEMTYPE= mtype >>;

  • CONTENTS < option(s) >;

    COPY OUT= libref-1

    • <CLONENOCLONE>

      <CONSTRAINT=YESNO>

      <DATECOPY>

      <FORCE>

      <IN= libref-2 >

      <INDEX=YESNO>

      <MEMTYPE=( mtype(s) )>

      <MOVE <ALTER= alter-password >>;

    • EXCLUDE SAS-file(s) < / MEMTYPE= mtype >;

      SELECT SAS-file(s)

      • </ <ALTER= alter-password >

        <MEMTYPE= mtype >>;

  • DELETE SAS-file(s)

    • </ <ALTER= alter-password >

      <GENNUM=ALLHISTREVERT integer >

      <MEMTYPE= mtype >>;

  • EXCHANGE name-1=other-name-1

    • < name-n=other-name-n >

      </ <ALTER= alter-password >

      <MEMTYPE= mtype >>;

  • MODIFY SAS-file <( option(s) )>

    • </ <CORRECTENCODING= encoding-value >

      <DTC= SAS-date-time >

      <GENNUM= integer >

      <MEMTYPE= mtype >>;

    • FORMAT variable-list-1 < format-1 >

      • < variable-list-n < format-n >>;

    • IC CREATE < constraint-name => constraint

      • <MESSAGE= message-string <MSGTYPE= USER >>;

    • IC DELETE constraint-name(s) _ALL_;

      IC REACTIVATE foreign-key-name REFERENCES libref ;

      INDEX CENTILES index(s)

      • </ <REFRESH>

        <UPDATECENTILES= ALWAYSNEVER integer >>;

    • INDEX CREATE index-specification(s)

      • </ <NOMISS>

        <UNIQUE>

        <UPDATECENTILES=ALWAYSNEVER integer >>;

    • INDEX DELETE index(s) _ALL_;

      INFORMAT variable-list-1 < informat-1 >

      • < variable-list-n < informat-n >>;

    • LABEL variable-1 =< label-1 >

      • < variable-n =< label-n >>;

    • RENAME old-name-1=new-name-1

      • < old-name-n=new-name-n >;

  • REPAIR SAS-file(s)

    • </ <ALTER= alter-password >

      <GENNUM= integer >

      <MEMTYPE= mtype >>;

  • SAVE SAS-file(s) </ MEMTYPE= mtype >;

PROC DATASETS Statement

PROC DATASETS < option(s) >;

To do this

Use this option

Specify the procedure input library

LIBRARY=

Provide alter access to any alter-protected SAS file in the SAS data library

ALTER=

Include information in the log about the number of observations, number of variables , number of indexes, and data set labels

DETAILS NODETAILS

Force a RUN group to execute even when there are errors

FORCE

Force an append operation

FORCE

Restrict processing for generation data sets

GENNUM=

Delete SAS files

KILL

Restrict processing to a certain type of SAS file

MEMTYPE=

Suppress the printing of the directory

NOLIST

Suppress error processing

NOWARN

Provide read, write, or alter access

PW=

Provide read access

READ=

Options

ALTER= alter-password

  • provides the alter password for any alter-protected SAS files in the SAS data library.

    See also: Using Passwords with the DATASETS Procedure on page 355

DETAILSNODETAILS

  • determines whether the following columns are written to the log:

    Obs, Entries, or Indexes

    • gives the number of observations for SAS files of type AUDIT, DATA, and VIEW; the number of entries for type CATALOG; and the number of files of type INDEX that are associated with a data file, if any. If SAS cannot determine the number of observations in a SAS data set, the value in this column is set to missing. For example, in a very large data set, if the number of observations or deleted observations exceeds the number that can be stored in a double-precision integer, the count will show as missing. The value for type CATALOG is the total number of entries. For other types, this column is blank.

      Tip: The value for files of type INDEX includes both user-defined indexes and indexes created by integrity constraints. To view index ownership and attribute information, use PROC DATASETS with the CONTENTS statement and the OUT2 option.

  • Vars

    • gives the number of variables for types AUDIT, DATA and VIEW. If SAS cannot determine the number of variables in the SAS data set, the value in this column is set to missing. For other types, this column is blank.

  • Label

    • contains the label associated with the SAS data set. This column prints a label only for the type DATA.

      The DETAILS option affects output only when a directory is specified and requires read access to all read-protected SAS files in the SAS data library. If you do not supply the read password, the directory listing contains missing values for the columns produced by the DETAILS option.

      Default: If neither DETAILS or NODETAILS is specified, the default is the system option setting. The default system option setting is NODETAILS.

      Tip: If you are using the SAS windowing environment and specify the DETAILS option for a library that contains read-protected SAS files, a requestor window prompts you for each read password that you do not specify in the PROC DATASETS statement. Therefore, you may want to assign the same read password to all SAS files in the same SAS data library.

      Featured in: Example 1 on page 372

FORCE

  • performs two separate actions:

    • forces a RUN group to execute even if errors are present in one or more statements in the RUN group. See RUN-Group Processing on page 353 for a discussion of RUN-group processing and error handling.

    • forces all APPEND statements to concatenate two data sets even when the variables in the data sets are not exactly the same. The APPEND statement drops the extra variables and issues a warning message. Without the FORCE option, the procedure issues an error message and stops processing if you try to perform an append operation with two SAS data sets whose variables are not exactly the same. Refer to APPEND Statement on page 309 for more information on the FORCE option.

GENNUM=ALLHISTREVERT integer

  • restricts processing for generation data sets. Valid values are as follows :

    ALL

    • for subordinate CHANGE and DELETE statements, refers to the base version and all historical versions in a generation group.

  • HIST

    • for a subordinate DELETE statement, refers to all historical versions, but excludes the base version in a generation group.

  • REVERT 0

    • for a subordinate DELETE statement, refers to the base version in a generation group and changes the most current historical version, if it exists, to the base version.

  • integer

    • for subordinate AUDIT, CHANGE, MODIFY, DELETE, and REPAIR statements, refers to a specific version in a generation group. Specifying a positive number is an absolute reference to a specific generation number that is appended to a data set name; that is, gennum=2 specifies MYDATA#002. Specifying a negative number is a relative reference to a historical version in relation to the base version, from the youngest to the oldest; that is, gennum=-1 refers to the youngest historical version.

  • See also: Restricting Processing for Generation Data Sets on page 358

    See also: Understanding Generation Data Sets in SAS Language Reference: Concepts

KILL

  • deletes all SAS files in the SAS data library that are available for processing. The MEMTYPE= option subsets the member types that the statement deletes.

    CAUTION:

    • The KILL option deletes the SAS files immediately after you submit the statement.

LIBRARY= libref

  • names the library that the procedure processes. This library is the procedure input library .

    Aliases: DDNAME=, DD=, LIB=

    Default: WORK or USER. See Temporary and Permanent SAS Data Sets on page 16 for more information on the WORK and USER libraries.

    Restriction: A SAS library that is accessed via a sequential engine (such as a tape format engine) cannot be specified as the value of the LIBRARY= option.

    Featured in: Example 1 on page 372

MEMTYPE=( mtype(s) )

  • restricts processing to one or more member types and restricts the listing of the data library directory to SAS files of the specified member types. For example, the following PROC DATASETS statement limits processing to SAS data sets in the default data library and limits the directory listing in the SAS log to SAS files of member type DATA:

     proc datasets memtype=data; 

    Aliases: MTYPE=, MT=

    Default: ALL

    See also: Restricting Member Types for Processing on page 356

NODETAILS

  • See the description of DETAILS on page 305.

NOLIST

  • suppresses the printing of the directory of the SAS files in the SAS log.

    Featured in: Example 3 on page 378

    Note: If you specify the ODS RTF destination, PROC DATASETS output will go to both the SAS log and the ODS output area. The NOLIST option will suppress output to both. To see the output only in the SAS log, use the ODS EXCLUDE statement by specifying the member directory as the exclusion.

NOWARN

  • suppresses the error processing that occurs when a SAS file that is specified in a SAVE, CHANGE, EXCHANGE, REPAIR, DELETE, or COPY statement or listed as the first SAS file in an AGE statement is not in the procedure input library. When an error occurs and the NOWARN option is in effect, PROC DATASETS continues processing that RUN group. If NOWARN is not in effect, PROC DATASETS stops processing that RUN group and issues a warning for all operations except DELETE, for which it does not stop processing.

PW= password

  • provides the password for any protected SAS files in the SAS data library. PW= can act as an alias for READ=, WRITE=, or ALTER=.

    See also: Using Passwords with the DATASETS Procedure on page 355

READ= read-password

  • provides the read-password for any read-protected SAS files in the SAS data library.

    See also: Using Passwords with the DATASETS Procedure on page 355

AGE Statement

Renames a group of related SAS files in a library.

Featured in: Example 6 on page 385

AGE current-name related-SAS-file(s)

  • </ <ALTER= alter-password >

    <MEMTYPE= mtype >>;

Required Arguments

current-name

  • is a SAS file that the procedure renames. current-name receives the name of the first name in related-SAS-file(s) .

related-SAS-file(s)

  • is one or more SAS files in the SAS data library.

Options

ALTER= alter-password

  • provides the alter password for any alter-protected SAS files named in the AGE statement. Because an AGE statement renames and deletes SAS files, you need alter access to use the AGE statement. You can use the option either in parentheses after the name of each SAS file or after a forward slash.

    See also: Using Passwords with the DATASETS Procedure on page 355

MEMTYPE= mtype

  • restricts processing to one member type. All of the SAS files that you name in the AGE statement must be the same member type. You can use the option either in parentheses after the name of each SAS file or after a forward slash.

    Aliases: MTYPE=, MT=

    Default: If you do not specify MEMTYPE= in the PROC DATASETS statement, the default is DATA.

    See also: Restricting Member Types for Processing on page 356

Details

  • The AGE statement renames current-name to the name of the first name in related-SAS-file(s) , renames the first name in related-SAS-file(s) to the second name in related-SAS-file(s) , and so on until it changes the name of the next -to-last SAS file in related-SAS-file(s) to the last name in related-SAS-file(s) . The AGE statement then deletes the last file in related-SAS-file(s) .

  • If the first SAS file named in the AGE statement does not exist in the SAS data library, PROC DATASETS stops processing the RUN group containing the AGE statement and issues an error message. The AGE statement does not age any of the related-SAS-file(s) . To override this behavior, use the NOWARN option in the PROC DATASETS statement.

    If one of the related-SAS-file(s) does not exist, the procedure prints a warning message to the SAS log but continues to age the SAS files that it can.

  • If you age a data set that has an index, the index continues to correspond to the data set.

  • You can age only entire generation groups. For example, if data sets A and B have generation groups, then the following statement deletes generation group B and ages (renames) generation group A to the name B:

     age a b; 

    For example, suppose the generation group for data set A has 3 historical versions and the generation group for data set B has 2 historical versions. Then aging A to B has this effect:

    Old Name

    Version

    New Name

    Version

    A

    base

    B

    base

    A

    1

    B

    1

    A

    2

    B

    2

    A

    3

    B

    3

    B

    base

    is deleted

     

    B

    1

    is deleted

     

    B

    2

    is deleted

     

APPEND Statement

Adds the observations from one SAS data set to the end of another SAS data set.

Reminder: You can specify most data set options for the BASE= argument and DATA= option. However, you cannot specify the DROP=, KEEP=, or RENAME= data set option for the BASE= data set. If specified, these options are ignored and a warning is written to the log. See Data Set Options on page 18 for a list. You can use any global statements as well. See Global Statements on page 18.

Requirement: The BASE= data set must be a member of a SAS library that supports update processing.

Default: If the BASE= data set is accessed through a SAS server and if no other user has the data set open at the time the APPEND statement begins processing, the BASE= data set defaults to CNTLLEV=MEMBER (member-level locking). When this happens, no other user can update the file while the data set is processed .

Tip: If a failure occurs during processing, the data set is marked as damaged and is reset to its pre-append condition at the next REPAIR statement. If the data set has an index, the index is not updated with each observation but is updated once at the end. (This is Version 7 and later behavior, as long as APPENDVER=V6 is not set.)

Featured in: Example 5 on page 383

APPEND BASE=< libref. > SAS-data-set

  • APPENDVER=V6>

    <DATA=< libref .> SAS-data-set >

    <FORCE>;

Required Arguments

BASE=< libref. > SAS-data-set

  • names the data set to which you want to add observations.

    libref

    • specifies the library that contains the SAS data set. If you omit the libref , the default is the libref for the procedure input library. If you are using PROC APPEND, the default for libref is either WORK or USER.

  • SAS-data-set

    • names a SAS data set. If the APPEND statement cannot find an existing data set with this name, it creates a new data set in the library. That is, you can use the APPEND statement to create a data set by specifying a new data set name in the BASE= argument.

  • The BASE= data set is the current SAS data set after all append operations regardless of whether you are creating a new data set or appending to an existing data set.

    Alias: OUT=

    Featured in: Example 5 on page 383

    Note: The following WARNING appears in the log if you specify the DROP=, KEEP=, or RENAME= data set option for the BASE= data set:

     WARNING: The DROP, KEEP or RENAME data set options are ignored for the BASE data set. 

Options

APPENDVER=V6

  • uses the Version 6 behavior for appending observations to the BASE= data set, which is to append one observation at a time. Beginning in Version 7, to improve performance, the default behavior changed so that all observations are appended after the data set is processed.

    See also: Appending to an Indexed Data Set ” Fast-Append Method on page 312

DATA=< libref. > SAS-data-set

  • names the SAS data set containing observations that you want to append to the end of the SAS data set specified in the BASE= argument.

    libref

    • specifies the library that contains the SAS data set. If you omit libref , the default is the libref for the procedure input library. The DATA= data set can be from any SAS data library, but you must use the two-level name if the data set resides in a library other than the procedure input library.

  • SAS-data-set

    • names a SAS data set. If the APPEND statement cannot find an existing data set with this name, it stops processing.

  • Alias: NEW=

    Default: the most recently created SAS data set, from any SAS data library

    See also: Appending with Generation Groups on page 315

    Featured in: Example 5 on page 383

FORCE

  • forces the APPEND statement to concatenate data sets when the DATA= data set contains variables that either

    • are not in the BASE= data set

    • do not have the same type as the variables in the BASE= data set

    • are longer than the variables in the BASE= data set.

  • See also: Appending to Data Sets with Different Variables on page 313

    See also: Appending to Data Sets That Contain Variables with Different Attributes on page 313

    Featured in: Example 5 on page 383

    Tip: You can use the GENNUM= data set option to append to or from a specific version in a generation group. Here are some examples:

     /* appends historical version to base A */  proc datasets;     append base=a        data=a (gennum=2);         /* appends current version of A to historical version */  proc datasets;     append base=a (gennum=1)        data=a; 

Restricting the Observations That Are Appended

You can use the WHERE= data set option with the DATA= data set in order to restrict the observations that are appended. Likewise, you can use the WHERE statement in order to restrict the observations from the DATA= data set. The WHERE statement has no effect on the BASE= data set. If you use the WHERE= data set option with the BASE= data set, WHERE= has no effect.

CAUTION:

  • For an existing BASE= data set: If there is a WHERE statement on the BASE= data set, it will take effect only if the WHEREUP= option is set to YES.

CAUTION:

  • For the non-existent BASE= data set: If there is a WHERE statement on the non-existent BASE= data set, regardless of the WHEREUP option setting, you use the WHERE statement.

Note: You cannot append a data set to itself by using the WHERE= data set option.

Choosing between the SET Statement and the APPEND Statement

If you use the SET statement in a DATA step to concatenate two data sets, SAS must process all the observations in both data sets to create a new one. The APPEND statement bypasses the processing of data in the original data set and adds new observations directly to the end of the original data set. Using the APPEND statement can be more efficient than using a SET statement if

  • the BASE= data set is large

  • all variables in the BASE= data set have the same length and type as the variables in the DATA= data set and if all variables exist in both data sets.

  • Note: You can use the CONTENTS statement to see the variable lengths and types.

The APPEND statement is especially useful if you frequently add observations to a SAS data set (for example, in production programs that are constantly appending data to a journal-type data set).

Appending Password-Protected SAS Data Sets

In order to use the APPEND statement, you need read access to the DATA= data set and write access to the BASE= data set. To gain access, use the READ= and WRITE= data set options in the APPEND statement the way you would use them in any other SAS statement, which is in parentheses immediately after the data set name. When you are appending password-protected data sets, use the following guidelines:

  • If you do not give the read password for the DATA= data set in the APPEND statement, by default the procedure looks for the read password for the DATA= data set in the PROC DATASETS statement. However, the procedure does not look for the write password for the BASE= data set in the PROC DATASETS statement. Therefore, you must specify the write password for the BASE= data set in the APPEND statement.

  • If the BASE= data set is read-protected only, you must specify its read password in the APPEND statement.

Appending to a Compressed Data Set

You can concatenate compressed SAS data sets. Either or both of the BASE= and DATA= data sets can be compressed. If the BASE= data set allows the reuse of space from deleted observations, the APPEND statement may insert the observations into the middle of the BASE= data set to make use of available space.

For information on the COMPRESS= and REUSE= data set and system options, see SAS Language Reference: Dictionary .

Appending to an Indexed Data Set ” Fast-Append Method

Beginning with Version 7, the behavior of appending to an indexed data set changed to improve performance.

  • In Version 6, when you appended to an indexed data set, the index was updated for each added observation. Index updates tend to be random; therefore, disk I/O could have been high.

  • Currently, SAS does not update the index until all observations are added to the data set. After the append, SAS internally sorts the observations and inserts the data into the index in sequential order, which reduces most of the disk I/O and results in a faster append method.

The fast-append method is used by default when the following requirements are met; otherwise , the Version 6 method is used:

  • The BASE= data set is open for member-level locking. If CNTLLEV= is set to record, then the fast-append method is not used.

  • The BASE= data set does not contain referential integrity constraints.

  • The BASE= data set is not accessed using the Cross Environment Data Access (CEDA) facility.

  • The BASE= data set is not using a WHERE= data set option.

To display information in the SAS log about the append method that is being used, you can specify the MSGLEVEL= system option as follows:

 options msglevel=i; 

Either a message displays if the fast-append method is in use or a message or messages display as to why the fast-append method is not in use.

The current append method initially adds observations to the BASE= data set regardless of the restrictions that are determined by the index. For example, a variable that has an index that was created with the UNIQUE option does not have its values validated for uniqueness until the index is updated. Then, if a nonunique value is detected , the offending observation is deleted from the data set. This means that after observations are appended, some of them may subsequently be deleted.

For a simple example, consider that the BASE= data set has ten observations numbered from 1 to 10 with a UNIQUE index for the variable ID. You append a data set that contains five observations numbered from 1 to 5, and observations 3 and 4 both contain the same value for ID. The following occurs

  1. After the observations are appended, the BASE= data set contains 15 observations numbered from 1 to 15.

  2. SAS updates the index for ID, validates the values, and determines that observations 13 and 14 contain the same value for ID.

  3. SAS deletes one of the observations from the BASE= data set, resulting in 14 observations that are numbered from 1 to 15. For example, observation 13 is deleted. Note that you cannot predict which observation will be deleted, because the internal sort may place either observation first. (In Version 6, you could predict that observation 13 would be added and observation 14 would be rejected.)

If you do not want the current behavior (which could result in deleted observations) or if you want to be able to predict which observations are appended, request the Version 6 append method by specifying the APPENDVER=V6 option:

 proc datasets;     append base=a data=b appendver=v6;  run; 

Note: In Version 6, deleting the index and then recreating it after the append could improve performance. The current method may eliminate the need to do that. However, the performance depends on the nature of your data.

Appending to Data Sets with Different Variables

If the DATA= data set contains variables that are not in the BASE= data set, use the FORCE option in the APPEND statement to force the concatenation of the two data sets. The APPEND statement drops the extra variables and issues a warning message.

If the BASE= data set contains a variable that is not in the DATA= data set, the APPEND statement concatenates the data sets, but the observations from the DATA= data set have a missing value for the variable that was not present in the DATA= data set. The FORCE option is not necessary in this case.

Appending to Data Sets That Contain Variables with Different Attributes

  • If a variable has different attributes in the BASE= data set than it does in the DATA= data set, the attributes in the BASE= data set prevail.

  • If formats in the DATA= data set are different from those in the BASE= data set, then the formats in the BASE= data set are used. However, SAS does not convert the data from the DATA= data set in order to be consistent with the formats in the BASE= data set. The result could be data that appears to be incorrect. A warning message is displayed in the SAS log. The following example illustrates appending data by using different formats:

     data format1;     input Date date9.;     format Date date9.;     datalines;  24sep1975  22may1952  ;  data format2;     input Date datetime20.;     format Date datetime20.;     datalines;  25aug1952:11:23:07.4  ;  proc append base=format1 data=format2;  run; 

    The following messages are displayed in the SAS log.

Output 15.2: Warning Message in SAS Log
start example
 NOTE: Appending WORK.FORMAT2 to WORK.FORMAT1.  WARNING: Variable Date has format DATE9. on the BASE data set     and format DATETIME20. on the DATA data set. DATE9. used.  NOTE: There were 1 observations read from the data set WORK.FORMAT2.  NOTE: 1 observations added.  NOTE: The data set WORK.FORMAT1 has 3 observations and 1 variables. 
end example
 
  • If the length of a variable is longer in the DATA= data set than in the BASE= data set, or if the same variable is a character variable in one data set and a numeric variable in the other, use the FORCE option. Using FORCE has these consequences:

    • The length of the variables in the BASE= data set takes precedence. SAS truncates values from the DATA= data set to fit them into the length that is specified in the BASE= data set.

    • The type of the variables in the BASE= data set takes precedence. The APPEND statement replaces values of the wrong type (all values for the variable in the DATA= data set) with missing values.

Appending Data Sets That Contain Integrity Constraints

If the DATA= data set contains integrity constraints and the BASE= data set does not exist, the APPEND statement copies the general constraints. Note that the referential constraints are not copied . If the BASE= data set exists, the APPEND action copies only observations.

Appending with Generation Groups

You can use the GENNUM= data set option to append to a specific version in a generation group. Here are examples:

SAS Statements

Result

  proc datasets;   append base=a   data=b(gennum=2);  

appends historical version B#002 to base A

  proc datasets;   append base=a(gennum=2)   data=b(gennum=2);  

appends historical version B#002 to historical version A#002

Using the APPEND Procedure instead of the APPEND Statement

The only difference between the APPEND procedure and the APPEND statement in PROC DATASETS, is the default for libref in the BASE= and DATA= arguments. For PROC APPEND, the default is either WORK or USER. For the APPEND statement, the default is the libref of the procedure input library.

System Failures

If a system failure or some other type of interruption occurs while the procedure is executing, the append operation may not be successful; it is possible that not all, perhaps none, of the observations will be added to the BASE= data set. In addition, the BASE= data set may suffer damage. The APPEND operation performs an update in place, which means that it does not make a copy of the original data set before it begins to append observations. If you want to be able to restore the original observations, you can initiate an audit trail for the base data file and select to store a before-update image of the observations. Then you can write a DATA step to extract and reapply the original observations to the data file. For information about initiating an audit trail, see the PROC DATASETS AUDIT Statement on page 315.

AUDIT Statement

Initiates and controls event logging to an audit file as well as suspends, resumes, or terminates event logging in an audit file.

See also: Understanding an Audit Trail in SAS Language Reference: Concepts

Tip: The AUDIT statement takes one of two forms, depending on whether you are initiating the audit trail or suspending, resuming, or terminating event logging in an audit file.

AUDIT SAS-file <( SAS-password )>;

  • INITIATE

    • AUDIT_ALL=NOYES>;

      • LOG <ADMIN_IMAGE=YESNO>

        <BEFORE_IMAGE=YESNO>

        <DATA_IMAGE=YESNO>

        <ERROR_IMAGE=YESNO>>;

        <USER_VAR variable-1 < variable-n >>;

AUDIT SAS-file <(< SAS-password > <GENNUM= integer >)>;

  • SUSPENDRESUMETERMINATE;

Required Arguments and Statements

SAS-file

  • specifies the SAS data file in the procedure input library that you want to audit.

INITIATE

  • creates an audit file that has the same name as the SAS data file and a data set type of AUDIT. The audit file logs additions, deletions, and updates to the SAS data file. You must initiate an audit trail before you can suspend, resume, or terminate it.

Options

SAS-password

  • specifies the password for the SAS data file, if one exists. The parentheses are required.

GENNUM= integer

  • specifies that the SUSPEND, RESUME, or TERMINATE action be performed on the audit trail of a generation file. You cannot initiate an audit trail on a generation file. Valid values for GENNUM= are integer , which is a number that references a specific version from a generation group. Specifying a positive number is an absolute reference to a specific generation number that is appended to a data set s name; that is, gennum=2 specifies MYDATA#002. Specifying a negative number is a relative reference to a historical version in relation to the base version, from the youngest to the oldest; that is, gennum=-1 refers to the youngest historical version. Specifying 0, which is the default, refers to the base version. The parentheses are required.

AUDIT_ALL=NOYES

  • specifies whether logging can be suspended and audit settings can be changed. AUDIT_ALL=YES specifies that all images are logged and cannot be suspended . That is, you cannot use the LOG statement to turn off logging of particular images, and you cannot suspend event logging by using the SUSPEND statement. To turn off logging, you must use the TERMINATE statement, which terminates event logging and deletes the audit file.

    Default: NO

LOG

  • specifies the audit settings:

    ADMIN_IMAGE=YESNO

    • controls the logging of administrative events to the audit file (that is, the SUSPEND and RESUME actions).

  • BEFORE_IMAGE=YESNO

    • controls the storage of before-update record images.

  • DATA_IMAGE=YESNO

    • controls the storage of added, deleted, and after-update record images.

  • ERROR_IMAGE=YESNO

    • controls the storage of unsuccessful after-update record images.

  • Default: All images are logged by default; that is, all four are set to YES.

    Tip: If you do not want to log a particular image, specify NO for the image type. For example, the following code turns off logging the error images, but the administrative, before, and data images continue to be logged:

     log error_image=no; 

USER_VAR variable-1 < variable-n >

  • defines optional variables to be logged in the audit file with each update to an observation. The syntax for defining variables is

    • USER_VAR variable-name-1 <$> < length > <LABEL= variable-label >
      < variable-name-n <$> < length > <LABEL= variable-label >>

  • where

    variable-name

    • is a name for the variable.

  • $

    • indicates that the variable is a character variable.

  • length

    • specifies the length of the variable. If a length is not specified, the default is 8.

  • LABEL= variable-label

    • specifies a label for the variable.

  • You can define attributes such as format and informat for the user variables in the data file by using the PROC DATASETS MODIFY statement.

SUSPEND

  • suspends event logging to the audit file, but does not delete the audit file.

RESUME

  • resumes event logging to the audit file, if it was suspended.

TERMINATE

  • terminates event logging and deletes the audit file.

Creating an Audit File

The following example creates the audit file MYLIB.MYFILE.AUDIT to log updates to the data file MYLIB.MYFILE.DATA, storing all available record images:

 proc datasets library=MyLib;     audit MyFile (alter=MyPassword);     initiate;  run; 

The following example creates the same audit file but stores only error record images:

 proc datasets library=MyLib;     audit MyFile (alter=MyPassword);     initiate        log data_image=NO before_image=NO;  run; 

CHANGE Statement

Renames one or more SAS files in the same SAS data library.

Featured in: Example 1 on page 372

CHANGE old-name-1=new-name-1

  • < old-name-n=new-name-n >

    </ <ALTER= alter-password >

    <GENNUM=ALL integer >

    <MEMTYPE= mtype >>;

Required Arguments

old-name=new-name

  • changes the name of a SAS file in the input data library. old-name must be the name of an existing SAS file in the input data library.

    Featured in: Example 1 on page 372

Options

ALTER= alter-password

  • provides the alter password for any alter-protected SAS files named in the CHANGE statement. Because a CHANGE statement changes the names of SAS files, you need alter access to use the CHANGE statement for new-name . You can use the option either in parentheses after the name of each SAS file or after a forward slash.

    See also: Using Passwords with the DATASETS Procedure on page 355

GENNUM=ALL integer

  • restricts processing for generation data sets. You can use the option either in parentheses after the name of each SAS file or after a forward slash. Valid values are

    ALL 0

    • refers to the base version and all historical versions of a generation group.

  • integer

    • refers to a specific version from a generation group. Specifying a positive number is an absolute reference to a specific generation number that is appended to a data set s name; that is, gennum=2 specifies MYDATA#002. Specifying a negative number is a relative reference to a historical version in relation to the base version, from the youngest to the oldest; that is, gennum=-1 refers to the youngest historical version.

      For example, the following statements change the name of version A#003 to base B:

       proc datasets;     change A=B / gennum=3;  proc datasets;     change A(gennum=3)=B; 

      The following CHANGE statement produces an error:

       proc datasets;     change A(gennum=3)=B(gennum=3); 
    • See also: Restricting Processing for Generation Data Sets on page 358

      See also: Understanding Generation Data Sets in SAS Language Reference: Concepts

MEMTYPE= mtype

  • restricts processing to one member type. You can use the option either in parentheses after the name of each SAS file or after a forward slash.

    Aliases: MTYPE=, MT=

    Default: If you do not specify MEMTYPE= in the PROC DATASETS statement, the default is MEMTYPE=ALL.

    See also: Restricting Member Types for Processing on page 356

Details

  • The CHANGE statement changes names by the order that the old-names occur in the directory listing, not in the order that you list the changes in the CHANGE statement.

  • If the old-name SAS file does not exist in the SAS data library, PROC DATASETS stops processing the RUN group containing the CHANGE statement and issues an error message. To override this behavior, use the NOWARN option in the PROC DATASETS statement.

  • If you change the name of a data set that has an index, the index continues to correspond to the data set.

CONTENTS Statement

Describes the contents of one or more SAS data sets and prints the directory of the SAS data library.

Reminder: You can use data set options with the DATA=, OUT=, and OUT2= options. See Data Set Options on page 18 for a list. You can use any global statements as well. See Global Statements on page 18.

Featured in: Example 4 on page 381

CONTENTS < option(s) >;

To do this

Use this option

Specify the input data set

DATA=

Specify the name for an output data set

OUT=

Specify the name of an output data set to contain information about indexes and integrity constraints

OUT2=

Include information in the output about the number of observations, number of variables, number of indexes, and data set labels

DETAILSNODETAILS

Print a list of the SAS files in the SAS data library

DIRECTORY

Print the length of a variable s informat or format

FMTLEN

Restrict processing to one or more types of SAS files

MEMTYPE=

Suppress the printing of individual files

NODS

Suppress the printing of the output

NOPRINT

Print a list of the variables by their position in the data set. By default, the CONTENTS statement lists the variables alphabetically .

VARNUM

Print a list of variables in alphabetical order even if they include mixed-case names

ORDER=IGNORECASE

Print abbreviated output

SHORT

Print centiles information for indexed variables

CENTILES

Options

CENTILES

  • prints centiles information for indexed variables.

    The following additional fields are printed in the default report of PROC CONTENTS when the CENTILES option is selected and an index exists on the data set. Note that the additional fields depend on whether the index is simple or complex.

    #

    number of the index on the data set.

    Index

    name of the index.

    Update Centiles

    percent of the data values that must be changed before the CENTILES for the indexed variables are automatically updated.

    Current Update Percent

    percent of index updated since CENTILES were refreshed.

    # of Unique Values

    number of unique indexed values.

    Variables

    names of the variables used to make up the index. Centile information is listed below the variables.

DATA= SAS-file-specification

  • specifies an entire library or a specific SAS data set within a library. SAS-file-specification can take one of the following forms:

    < libref. > SAS-data-set

    • names one SAS data set to process. The default for libref is the libref of the procedure input library. For example, to obtain the contents of the SAS data set HTWT from the procedure input library, use the following CONTENTS statement:

       contents data=HtWt; 

      To obtain the contents of a specific version from a generation group, use the GENNUM= data set option as shown in the following CONTENTS statement:

       contents data=HtWt(gennum=3); 

      < libref. >_ALL_

    • gives you information about all SAS data sets that have the type or types specified by the MEMTYPE= option. libref refers to the SAS data library. The default for libref is the libref of the procedure input library.

      • If you are using the _ALL_ keyword, you need read access to all read-protected SAS data sets in the SAS data library.

      • DATA=_ALL_ automatically prints a listing of the SAS files that are contained in the SAS library. Note that for SAS views, all librefs that are associated with the views must be assigned in the current session in order for them to be processed for the listing.

  • Default: most recently created data set in your job or session, from any SAS data library.

    Tip: If you specify a read-protected data set in the DATA= option but do not give the read password, by default the procedure looks in the PROC DATASETS statement for the read password. However, if you do not specify the DATA= option and the default data set (last one created in the session) is read protected, the procedure does not look in the PROC DATASETS statement for the read password.

    Featured in: Example 4 on page 381

DETAILSNODETAILS

  • DETAILS includes these additional columns of information in the output, but only if DIRECTORY is also specified.

    Default: If neither DETAILS or NODETAILS is specified, the defaults are as follows: for the CONTENTS procedure, the default is the system option setting, which is NODETAILS; for the CONTENTS statement, the default is whatever is specified on the PROC DATASETS statement, which also defaults to the system option setting.

    See also: description of the additional columns in Options in PROC DATASETS Statement on page 304

DIRECTORY

  • prints a list of all SAS files in the specified SAS data library. If DETAILS is also specified, using DIRECTORY causes the additional columns described in DETAILSNODETAILS on page 305 to be printed.

FMTLEN

  • prints the length of the informat or format. If you do not specify a length for the informat or format when you associate it with a variable, the length does not appear in the output of the CONTENTS statement unless you use the FMTLEN option. The length also appears in the FORMATL or INFORML variable in the output data set.

MEMTYPE=( mtype(s) )

  • restricts processing to one or more member types. The CONTENTS statement produces output only for member types DATA, VIEW, and ALL, which includes DATA and VIEW.

    MEMTYPE= in the CONTENTS statement differs from MEMTYPE= in most of the other statements in the DATASETS procedure in the following ways:

    • A slash does not precede the option.

    • You cannot enclose the MEMTYPE= option in parentheses to limit its effect to only the SAS file immediately preceding it.

  • MEMTYPE= results in a directory of the library in which the DATA= member is located. However, MEMTYPE= does not limit the types of members whose contents are displayed unless the _ALL_ keyword is used in the DATA= option. For example, the following statements produce the contents of only the SAS data sets with the member type DATA:

     proc datasets memtype=data;     contents data=_all_;  run; 

    Aliases: MT=, MTYPE=

    Default: DATA

NODS

  • suppresses printing the contents of individual files when you specify _ALL_ in the DATA= option. The CONTENTS statement prints only the SAS data library directory. You cannot use the NODS option when you specify only one SAS data set in the DATA= option.

NODETAILS

  • See the description of DETAILSNODETAILS on page 321.

NOPRINT

  • suppresses printing the output of the CONTENTS statement.

ORDER= IGNORECASE VARNUM

IGNORECASE

prints a list of variables in alphabetical order even if they include mixed-case names.

VARNUM

is the same as the VARNUM option. See VARNUM.

OUT= SAS-data-set

  • names an output SAS data set.

    Tip: OUT= does not suppress the printed output from the statement. If you want to suppress the printed output, you must use the NOPRINT option.

    See: The OUT= Data Set on page 366 for a description of the variables in the OUT= data set.

    See also: Example 7 on page 386 for an example of how to get the CONTENTS output into an ODS data set for processing.

OUT2= SAS-data-set

  • names the output data set to contain information about indexes and integrity constraints.

    Tip: If UPDATECENTILES was not specified in the index definition, then the default value of 5 is used in the RECREATE variable of the OUT2 data set.

    Tip: OUT2= does not suppress the printed output from the statement. To suppress the printed output, use the NOPRINT option.

    See also: The OUT2= Data Set on page 371 for a description of the variables in the OUT2= data set.

SHORT

  • prints only the list of variable names, the index information, and the sort information for the SAS data set.

VARNUM

  • prints a list of the variable names in the order of their logical position in the data set. By default, the CONTENTS statement lists the variables alphabetically. The physical position of the variable in the data set is engine-dependent.

Details

The CONTENTS statement prints an alphabetical listing of the variables by default, except for variables in the form of a numbered range list. Numbered range lists, such as x1 “x100, are printed in incrementing order, that is, x1 “x100. For more information, see Alphabetic List of Variables and Attributes on page 362.

Requesting CONTENTS Output for a Password-Protected File with Integrity Constraints

For a SAS data file with defined referential integrity constraints that is also password protected, some SAS requests require that both files be open in order to process the request. If both files are password protected, then both passwords must be provided.

For example, suppose you want to execute the CONTENTS procedure for a data file with a primary key that is referenced by a foreign key. You must provide the password for the primary key data file as well as the password for the referential data file, because in order to obtain the information for the CONTENTS output for the primary key data file, SAS must open both files.

For an example, see Understanding Integrity Constraints in SAS Language Reference: Concepts .

Using the CONTENTS Procedure instead of the CONTENTS Statement

The only difference between the CONTENTS procedure and the CONTENTS statement in PROC DATASETS is the default for libref in the DATA= option. For PROC CONTENTS, the default is either WORK or USER. For the CONTENTS statement, the default is the libref of the procedure input library.

COPY Statement

Copies all or some of the SAS files in a SAS library.

Featured in: Example 1 on page 372

COPY OUT= libref-1

  • <CLONENOCLONE>

    <CONSTRAINT=YESNO>

    <DATECOPY>

    <FORCE>

    <IN= libref-2 >

    <INDEX=YESNO>

    <MEMTYPE=( mtype(s) )>

    <MOVE <ALTER= alter-password >> ;

Required Arguments

OUT= libref-1

  • names the SAS library to copy SAS files to.

    Aliases: OUTLIB= and OUTDD=

    Featured in: Example 1 on page 372

Options

ALTER= alter-password

  • provides the alter password for any alter-protected SAS files that you are moving from one data library to another. Because the MOVE option deletes the SAS file from the original data library, you need alter access to move the SAS file.

    See also: Using Passwords with the DATASETS Procedure on page 355

CLONENOCLONE

  • specifies whether to copy the following data set attributes:

    • size of input/output buffers

    • whether the data set is compressed

    • whether free space is reused

    • data representation of input data set, library, or operating environment

    • encoding value.

  • These attributes are specified with data set options, SAS system options, and LIBNAME statement options:

    • BUFSIZE= value for the size of the input/output buffers

    • COMPRESS= value for whether the data set is compressed

    • REUSE= value for whether free space is reused

    • OUTREP= value for data representation

    • ENCODING= or INENCODING= for encoding value.

  • For the BUFSIZE= attribute, the following table summarizes how the COPY statement works:

Table 15.1: CLONE and the Buffer Page Size Attribute

If you use

the COPY statement

CLONE

uses the BUFSIZE= value from the input data set for the output data set.

NOCLONE

uses the current setting of the SAS system option BUFSIZE= for the output data set.

neither

determines the type of access method, sequential or random, used by the engine for the input data set and the engine for the output data set. If both engines use the same type of access, the COPY statement uses the BUFSIZE= value from the input data set for the output data set. If the engines do not use the same type of access, the COPY statement uses the setting of SAS system option BUFSIZE= for the output data set.

For the COMPRESS= and REUSE= attributes, the following table summarizes how the COPY statement works:

Table 15.2: CLONE and the Compression and Reuse Space Attributes

If you use

the COPY statement

CLONE

uses the values from the input data set for the output data set. If the engine for the input data set does not support the compression and reuse space attributes, then the COPY statement uses the current setting of the corresponding SAS system option.

NOCLONE

uses the current setting of the SAS system options COMPRESS= and REUSE= for the output data set.

neither

defaults to CLONE.

For the OUTREP= attribute, the following table summarizes how the COPY statement works:

Table 15.3: CLONE and the Data Representation Attribute

If you use

the COPY statement

CLONE

results in a copy with the data representation of the input data set.

NOCLONE

results in a copy with the data representation of the operating environment or, if specified, the value of the OUTREP= option in the LIBNAME statement for the library.

neither

default is CLONE.

Data representation is the format in which data is represented on a computer architecture or in an operating environment. For example, on an IBM PC, character data is represented by its ASCII encoding and byte-swapped integers. Native data representation refers to an environment for which the data representation compares with the CPU that is accessing the file. For example, a file in Windows data representation is native to the Windows operating environment.

For the ENCODING= attribute, the following table summarizes how the COPY statement works.

Table 15.4: CLONE and the Encoding Attribute

If you use

the COPY statement

CLONE

results in a copy that uses the encoding of the input data set or, if specified, the value of the INENCODING= option in the LIBNAME statement for the input library.

NOCLONE

results in a copy that uses the encoding of the current session encoding or, if specified, the value of the OUTENCODING= option in the LIBNAME statement for the output library.

neither

default is CLONE.

All data that is stored, transmitted, or processed by a computer is in an encoding. An encoding maps each character to a unique numeric representation. An encoding is a combination of a character set with an encoding method. A character set is the repertoire of characters and symbols that are used by a language or group of languages. An encoding method is the set of rules that are used to assign the numbers to the set of characters that will be used in a encoding.

CONSTRAINT=YESNO

  • specifies whether to copy all integrity constraints when copying a data set.

    Default: NO

    Tip: For data sets with integrity constraints that have a foreign key, the COPY statement copies the general and referential constraints if CONSTRAINT=YES is specified and the entire library is copied. If you use the SELECT or EXCLUDE statement to copy the data sets, then the referential integrity constraints are not copied. For more information, see Understanding Integrity Constraints in SAS Language Reference: Concepts .

DATECOPY

  • copies the SAS internal date and time when the SAS file was created and the date and time when it was last modified to the resulting copy of the file. Note that the operating environment date and time are not preserved.

    Restriction: DATECOPY cannot be used with encrypted files or catalogs.

    Restriction: DATECOPY can be used only when the resulting SAS file uses the V8 or V9 engine.

    Tip: You can alter the file creation date and time with the DTC= option on the MODIFY statement. See MODIFY Statement on page 344.

    Tip: If the file that you are copying has attributes that require additional processing, the last modified date is changed to the current date. For example, when you copy a data set that has an index, the index must be rebuilt, and this changes the last modified date to the current date. Other attributes that require additional processing and that could affect the last modified date include integrity constraints and a sort indicator.

FORCE

  • allows you to use the MOVE option for a SAS data set on which an audit trail exists.

    Note: The AUDIT file is not moved with the audited data set.

IN= libref-2

  • names the SAS library containing SAS files to copy.

    Aliases: INLIB= and INDD=

    Default: the libref of the procedure input library

    • To copy only selected members, use the SELECT or EXCLUDE statements.

INDEX=YESNO

  • specifies whether to copy all indexes for a data set when copying the data set to another SAS data library.

    Default: YES

MEMTYPE=( mtype(s) )

  • restricts processing to one or more member types.

    Aliases: MT=, MTYPE=

    Default: If you omit MEMTYPE= in the PROC DATASETS statement, the default is MEMTYPE=ALL.

    See also: Specifying Member Types When Copying or Moving SAS Files on page 327

    See also: Member Types on page 357

    Featured in: Example 1 on page 372

MOVE

  • moves SAS files from the input data library (named with the IN= option) to the output data library (named with the OUT= option) and deletes the original files from the input data library.

    Restriction: The MOVE option can be used to delete a member of a SAS library only if the IN= engine supports the deletion of tables. A tape format engine does not support table deletion. If you use a tape format engine, SAS suppresses the MOVE operation and prints a warning.

    Featured in: Example 1 on page 372

NOCLONE

  • See the description of CLONE.

Copying an Entire Library

To copy an entire SAS data library, simply specify an input data library and an output data library following the COPY statement. For example, the following statements copy all the SAS files in the SOURCE data library into the DEST data library:

 proc datasets library=source;     copy out=dest;  run; 

Copying Selected SAS Files

To copy selected SAS files, use a SELECT or EXCLUDE statement. For more discussion of using the COPY statement with a SELECT or an EXCLUDE statement, see Specifying Member Types When Copying or Moving SAS Files on page 327 and see Example 1 on page 372 for an example. Also, see EXCLUDE Statement on page 335 and SELECT Statement on page 352.

You can also select or exclude an abbreviated list of members. For example, the following statement selects members TABS, TEST1, TEST2, and TEST3:

 select tabs test1-test3; 

Also, you can select a group of members whose names begin with the same letter or letters by entering the common letters followed by a colon (:). For example, you can select the four members in the previous example and all other members having names that begin with the letter T by specifying the following statement:

 select t:; 

You specify members to exclude in the same way that you specify those to select. That is, you can list individual member names, use an abbreviated list, or specify a common letter or letters followed by a colon (:). For example, the following statement excludes the members STATS, TEAMS1, TEAMS2, TEAMS3, TEAMS4 and all the members that begin with the letters RBI from the copy operation:

 exclude stats teams1-teams4 rbi:; 

Note that the MEMTYPE= option affects which types of members are available to be selected or excluded.

When a SELECT or EXCLUDE statement is used with CONSTRAINT=YES, only the general integrity constraints on the data sets are copied. Any referential integrity constraints are not copied. For more information, see Understanding Integrity Constraints in SAS Language Reference: Concepts .

Specifying Member Types When Copying or Moving SAS Files

The MEMTYPE= option in the COPY statement differs from the MEMTYPE= option in other statements in the procedure in several ways:

  • A slash does not precede the option.

  • You cannot limit its effect to the member immediately preceding it by enclosing the MEMTYPE= option in parentheses.

  • The SELECT and EXCLUDE statements and the IN= option (in the COPY statement) affect the behavior of the MEMTYPE= option in the COPY statement according to the following rules:

    1. MEMTYPE= in a SELECT or EXCLUDE statement takes precedence over the MEMTYPE= option in the COPY statement. The following statements copy only VISION.CATALOG and NUTR.DATA from the default data library to the DEST data library; the MEMTYPE= value in the first SELECT statement overrides the MEMTYPE= value in the COPY statement.

       proc datasets;     copy out=dest memtype=data;        select vision(memtype=catalog) nutr;  run; 
    2. If you do not use the IN= option, or you use it to specify the library that happens to be the procedure input library, the value of the MEMTYPE= option in the PROC DATASETS statement limits the types of SAS files that are available for processing. The procedure uses the order of precedence described in rule 1 to further subset the types available for copying. The following statements do not copy any members from the default data library to the DEST data library; instead, the procedure issues an error message because the MEMTYPE= value specified in the SELECT statement is not one of the values of the MEMTYPE= option in the PROC DATASETS statement.

       /* This step fails! */  proc datasets memtype=(data program);     copy out=dest;        select apples / memtype=catalog;  run; 
    3. If you specify an input data library in the IN= option other than the procedure input library, the MEMTYPE= option in the PROC DATASETS statement has no effect on the copy operation. Because no subsetting has yet occurred, the procedure uses the order of precedence described in rule 1 to subset the types available for copying. The following statements successfully copy BODYFAT.DATA to the DEST data library because the SOURCE library specified in the IN= option in the COPY statement is not effected by the MEMTYPE= option in the PROC DATASETS statement.

       proc datasets library=work memtype=catalog;     copy in=source out=dest;        select bodyfat / memtype=data;  run; 

Copying Password-Protected SAS Files

You can copy a password-protected SAS file without specifying the password. In addition, because the password continues to correspond to the SAS file, you must know the password in order to access and manipulate the SAS file after you copy it.

Copying Data Sets with Long Variable Names

If the VALIDVARNAME=V6 system option is set and the data set has long variable names, the long variable names are truncated, unique variables names are generated, and the copy succeeds. The same is true for index names. If VALIDVARNAME=ANY or MIXEDCASE, the copy fails with an error if the OUT= engine does not support long variable names.

When a variable name is truncated, the variable name is shortened to eight bytes. If this name has already been defined in the data set, the name is shortened and a digit is added, starting with the number 2. The process of truncation and adding a digit continues until the variable name is unique. For example, a variable named LONGVARNAME becomes LONGVARN, provided that a variable with that name does not already exist in the data set. In that case, the variable name becomes LONGVAR2.

CAUTION:

  • Truncated variable names can collide with names already defined in the input data set.

    This is possible when the variable name that is already defined is exactly eight bytes long and ends in a digit. In that case, the truncated name is defined in the output data set and the name from the input data set is changed. For example,

     options validvarname=mixedcase;  data test;     lonvar10='aLongVariableName';     retain longvar1-longvar5 0;  run;  options validvarname=v6;  proc copy in=work out=sasuser;     select test;  run; 

    In this example, LONGVAR10 is truncated to LONVAR1 and placed in the output data set. Next, the original LONGVAR1 is copied. Its name is no longer unique and so it is renamed LONGVAR2. The other variables in the input data set are also renamed according to the renaming algorithm.

Using the COPY Procedure instead of the COPY Statement

Generally, the COPY procedure functions the same as the COPY statement in the DATASETS procedure. The differences are

  • The IN= argument is required with PROC COPY. In the COPY statement, IN= is optional. If omitted, the default value is the libref of the procedure input library.

  • PROC DATASETS cannot work with libraries that allow only sequential data access.

  • The COPY statement honors the NOWARN option but PROC COPY does not.

Copying Generation Groups

You can use the COPY statement to copy an entire generation group. However, you cannot copy a specific version in a generation group.

Transporting SAS Data Sets between Hosts

You use the COPY procedure, along with the XPORT engine, to transport SAS data sets between hosts. See Moving and Accessing SAS Files for more information and an example.

DELETE Statement

Deletes SAS files from a SAS data library.

Featured in: Example 1 on page 372

DELETE SAS-file(s)

  • </ <ALTER= alter-password >

    <GENNUM=ALLHISTREVERT integer >

    <MEMTYPE= mtype >>;

Required Arguments

SAS-file(s)

  • specifies one or more SAS files that you want to delete.

Options

ALTER= alter-password

  • provides the alter password for any alter-protected SAS files that you want to delete. You can use the option either in parentheses after the name of each SAS file or after a forward slash.

    See also: Using Passwords with the DATASETS Procedure on page 355

GENNUM=ALLHISTREVERT integer

  • restricts processing for generation data sets. You can use the option either in parentheses after the name of each SAS file or after a forward slash. Valid values are

    ALL

    • refers to the base version and all historical versions in a generation group.

  • HIST

    • refers to all historical versions, but excludes the base version in a generation group.

  • REVERT0

    • deletes the base version and changes the most current historical version, if it exists, to the base version.

  • integer

    • is a number that references a specific version from a generation group. Specifying a positive number is an absolute reference to a specific generation number that is appended to a data set s name; that is, gennum=2 specifies MYDATA#002. Specifying a negative number is a relative reference to a historical version in relation to the base version, from the youngest to the oldest; that is, gennum=-1 refers to the youngest historical version.

    See also: Restricting Processing for Generation Data Sets on page 358

    See also: Understanding Generation Data Sets in SAS Language Reference: Concepts

MEMTYPE= mtype

  • restricts processing to one member type. You can use the option either in parentheses after the name of each SAS file or after a forward slash.

    Aliases: MT=, MTYPE=

    Default: DATA

    See also: Restricting Member Types for Processing on page 356

    Featured in: Example 1 on page 372

Details

  • SAS immediately deletes SAS files when the RUN group executes. You do not have an opportunity to verify the delete operation before it begins.

  • If you attempt to delete a SAS file that does not exist in the procedure input library, PROC DATASETS issues a message and continues processing. If NOWARN is used, no message is issued.

  • When you use the DELETE statement to delete a data set that has indexes associated with it, the statement also deletes the indexes.

  • You cannot use the DELETE statement to delete a data file that has a foreign key integrity constraint or a primary key with foreign key references. For data files that have foreign keys, you must remove the foreign keys before you delete the data file. For data files that have primary keys with foreign key references, you must remove the foreign keys that reference the primary key before you delete the data file.

Working with Generation Groups

When you are working with generation groups, you can use the DELETE statement to

  • delete the base version and all historical versions

  • delete the base version and rename the youngest historical version to the base version

  • delete an absolute version

  • delete a relative version

  • delete all historical versions and leave the base version.

Deleting the Base Version and All Historical Versions

The following statements delete the base version and all historical versions where the data set name is A:

 proc datasets;     delete A(gennum=all);  proc datasets;     delete A / gennum=all;  proc datasets gennum=all;     delete A; 

The following statements delete the base version and all historical versions where the data set name begins with the letter A:

 proc datasets;     delete A:(gennum=all);  proc datasets;     delete A: / gennum=all;  proc datasets gennum=all;     delete A:; 
Deleting the Base Version and Renaming the Youngest Historical Version to the Base Version

The following statements delete the base version and rename the youngest historical version to the base version, where the data set name is A:

 proc datasets;     delete A(gennum=revert);  proc datasets;     delete A / gennum=revert;  proc datasets gennum=revert;     delete A; 

The following statements delete the base version and rename the youngest historical version to the base version, where the data set name begins with the letter A:

 proc datasets;     delete A:(gennum=revert);  proc datasets;     delete A: / gennum=revert;  proc datasets gennum=revert;     delete A:; 
Deleting a Version with an Absolute Number

The following statements use an absolute number to delete the first historical version:

 proc datasets;     delete A(gennum=1);  proc datasets;     delete A / gennum=1;  proc datasets gennum=1;     delete A; 

The following statements delete a specific historical version, where the data set name begins with the letter A:

 proc datasets;     delete A:(gennum=1);  proc datasets;     delete A: / gennum=1;  proc datasets gennum=1;     delete A:; 
Deleting a Version with a Relative Number

The following statements use a relative number to delete the youngest historical version, where the data set name is A:

 proc datasets;     delete A(gennum=-1);  proc datasets;     delete A / gennum=-1;  proc datasets gennum=-1;     delete A; 

The following statements use a relative number to delete the youngest historical version, where the data set name begins with the letter A:

 proc datasets;     delete A:(gennum=-1);  proc datasets;     delete A: / gennum=-1;  proc datasets gennum=-1;     delete A:; 
Deleting All Historical Versions and Leaving the Base Version

The following statements delete all historical versions and leave the base version, where the data set name is A:

 proc datasets;     delete A(gennum=hist);  proc datasets;     delete A / gennum=hist;  proc datasets gennum=hist;     delete A; 

The following statements delete all historical versions and leave the base version, where the data set name begins with the letter A:

 proc datasets;     delete A:(gennum=hist);  proc datasets;     delete A: / gennum=hist;  proc datasets gennum=hist;     delete A:; 

EXCHANGE Statement

Exchanges the names of two SAS files in a SAS library.

Featured in: Example 1 on page 372

EXCHANGE name-1=other-name-1

  • name-n=other-name-n >

    </ <ALTER= alter-password >

    <MEMTYPE= mtype >>;

Required Arguments

name=other-name

  • exchanges the names of SAS files in the procedure input library. Both name and other-name must already exist in the procedure input library.

Options

ALTER= alter-password

  • provides the alter password for any alter-protected SAS files whose names you want to exchange. You can use the option either in parentheses after the name of each SAS file or after a forward slash.

    See also: Using Passwords with the DATASETS Procedure on page 355

MEMTYPE= mtype

  • restricts processing to one member type. You can only exchange the names of SAS files of the same type. You can use the option either in parentheses after the name of each SAS file or after a forward slash.

    Default: If you do not specify MEMTYPE= in the PROC DATASETS statement, the default is ALL.

    See also: Restricting Member Types for Processing on page 356

Details

  • When you exchange more than one pair of names in one EXCHANGE statement, PROC DATASETS performs the exchanges in the order that the names of the SAS files occur in the directory listing, not in the order that you list the exchanges in the EXCHANGE statement.

  • If the name SAS file does not exist in the SAS data library, PROC DATASETS stops processing the RUN group that contains the EXCHANGE statement and issues an error message. To override this behavior, specify the NOWARN option in the PROC DATASETS statement.

  • The EXCHANGE statement also exchanges the associated indexes so that they correspond with the new name.

  • The EXCHANGE statement only allows two existing generation groups to exchange names. You cannot exchange a specific generation number with either an existing base version or another generation number.

EXCLUDE Statement

Excludes SAS files from copying.

Restriction: Must follow a COPY statement

Restriction: Cannot appear in the same COPY step with a SELECT statement

Featured in: Example 1 on page 372

EXCLUDE SAS-file(s) </ MEMTYPE= mtype >;

Required Arguments

SAS-file(s)

  • specifies one or more SAS files to exclude from the copy operation. All SAS files you name in the EXCLUDE statement must be in the library that is specified in the IN= option in the COPY statement. If the SAS files are generation groups, the EXCLUDE statement allows only selection of the base versions.

Options

MEMTYPE= mtype

  • restricts processing to one member type. You can use the option either in parentheses after the name of each SAS file or after a forward slash.

    Aliases: MTYPE=, MT=

    Default: If you do not specify MEMTYPE= in the PROC DATASETS statement, the COPY statement, or in the EXCLUDE statement, the default is MEMTYPE=ALL.

    See also: Restricting Member Types for Processing on page 356

    See also: Specifying Member Types When Copying or Moving SAS Files on page 327

Excluding Many Like-Named Files

You can use shortcuts for listing many SAS files in the EXCLUDE statement. For more information, see Shortcuts for Specifying Lists of Variable Names on page 24.

FORMAT Statement

Permanently assigns , changes, and removes variable formats in the SAS data set specified in the MODIFY statement.

Restriction: Must appear in a MODIFY RUN group

Featured in: Example 3 on page 378

FORMAT variable-list-1 < format-1 >

  • < variable-list-n < format-n >>;

Required Arguments

variable-list

  • specifies one or more variables whose format you want to assign, change, or remove. If you want to disassociate a format with a variable, list the variable last in the list with no format following. For example:

     format x1-x3 4.1 time hhmm2.2 age; 

Options

format

  • specifies a format to apply to the variable or variables listed before it. If you do not specify a format, the FORMAT statement removes any format associated with the variables in variable-list .

Note: You can use shortcut methods for specifying variables, such as the keywords _NUMERIC, _CHARACTER_, and _ALL_. See Shortcuts for Specifying Lists of Variable Names on page 24 for more information.

IC CREATE Statement

Creates an integrity constraint.

Restriction: Must be in a MODIFY RUN group

See also: Understanding Integrity Constraints in SAS Language Reference: Concepts

IC CREATE < constraint-name= > constraint <MESSAGE= message-string <MSGTYPE=USER>>;

Required Arguments

constraint

  • is the type of constraint. Valid values are as follows:

    NOT NULL ( variable )

    • specifies that variable does not contain a SAS missing value, including special missing values.

  • UNIQUE ( variables )

    • specifies that the values of variables must be unique. This constraint is identical to DISTINCT.

  • DISTINCT ( variables )

    • specifies that the values of variables must be unique. This constraint is identical to UNIQUE.

  • CHECK (WHERE- expression )

    • limits the data values of variables to a specific set, range, or list of values. This is accomplished with a WHERE expression.

  • PRIMARY KEY ( variables )

    • specifies a primary key, that is, a set of variables that do not contain missing values and whose values are unique.

      Interaction: A primary key affects the values of an individual data file until it has a foreign key referencing it.

      Requirement: When defining overlapping primary key and foreign key constraints, which means that variables in a data file are part of both a primary key and a foreign key definition, if you use exactly the same variables, then the variables must be defined in a different order.

  • FOREIGN KEY ( variables ) REFERENCES table-name

    • ON DELETE referential-action > <ON UPDATE referential-action > specifies a foreign key, that is, a set of variables whose values are linked to the values of the primary key variables in another data file. The referential actions are enforced when updates are made to the values of a primary key variable that is referenced by a foreign key.

      There are three types of referential actions: RESTRICT, SET NULL, and CASCADE:

      • For a RESTRICT referential action,

    • a delete operation

      • deletes the primary key row, but only if no foreign key values match the deleted value.

    • an update operation

      • updates the primary key value, but only if no foreign key values match the current value to be updated.

        For a SET NULL referential action,

    • a delete operation

      • deletes the primary key row and sets the corresponding foreign key values to NULL.

    • an update operation

      • modifies the primary key value and sets all matching foreign key values to NULL.

        For a CASCADE referential action,

    • an update operation

      • modifies the primary key value, and additionally modifies any matching foreign key values to the same value. CASCADE is not supported for delete operations.

Default: RESTRICT is the default action if no referential action is specified.

Interaction: Before it will enforce a SET NULL or CASCADE referential action, SAS checks to see if there are other foreign keys that reference the primary key and that specify RESTRICT for the intended operation. If RESTRICT is specified, or if the constraint reverts to the default values, then RESTRICT is enforced for all foreign keys, unless no foreign key values match the values to updated or deleted.

Requirement: When defining overlapping primary key and foreign key constraints, which means that variables in a data file are part of both a primary key and a foreign key definition,

  • if you use exactly the same variables, then the variables must be defined in a different order.

  • the foreign key s update and delete referential actions must both be RESTRICT.

Options

< constraint-name= >

  • is an optional name for the constraint. The name must be a valid SAS name. When you do not supply a constraint name, a default name is generated. This default constraint name has the following form

    Default name

    Constraint type

    _NM xxxx _

    Not Null

    _UN xxxx _

    Unique

    _CK xxxx _

    Check

    _PK xxxx _

    Primary key

    _FK xxxx _

    Foreign key

    where xxxx is a counter beginning at 0001.

    Note: The names PRIMARY, FOREIGN, MESSAGE, UNIQUE, DISTINCT, CHECK, and NOT cannot be used as values for constraint-name .

<MESSAGE= message-string <MSGTYPE=USER>>

  • message-string is the text of an error message to be written to the log when the data fails the constraint. For example,

     ic create not null(socsec)     message=Invalid Social Security number'; 

    Length: The maximum length of the message is 250 characters.

    <MSGTYPE=USER> controls the format of the integrity constraint error message. By default when the MESSAGE= option is specified, the message you define is inserted into the SAS error message for the constraint, separated by a space. MSGTYPE=USER suppresses the SAS portion of the message.

The following examples show how to create integrity constraints:

 ic create a = not null(x);  ic create Unique_D = unique(d);  ic create Distinct_DE = distinct(d e);  ic create E_less_D = check(where=(e < d or d = 99));  ic create primkey = primary key(a b);  ic create forkey = foreign key (a b) references table-name    on update cascade on delete set null;  ic create not null (x); 

Note that for a referential constraint to be established, the foreign key must specify the same number of variables as the primary key, in the same order, and the variables must be of the same type (character/numeric) and length.

IC DELETE Statement

Deletes an integrity constraint.

Restriction: Must be in a MODIFY RUN group

See also: Understanding Integrity Constraints in SAS Language Reference: Concepts

IC DELETE constraint-name(s) _ALL_;

Arguments

constraint-name(s)

  • names one or more constraints to delete. For example, to delete the constraints Unique_D and Unique_E, use this statement:

     ic delete Unique_D Unique_E; 

_ALL_

  • deletes all constraints for the SAS data file specified in the preceding MODIFY statement.

IC REACTIVATE Statement

Reactivates a foreign key integrity constraint that is inactive.

Restriction: Must be in a MODIFY RUN group

See also: Understanding Integrity Constraints in SAS Language Reference: Concepts

IC REACTIVATE foreign-key-name REFERENCES libref ;

Arguments

foreign-key-name

  • is the name of the foreign key to reactivate.

libref

  • refers to the SAS library containing the data set that contains the primary key that is referenced by the foreign key.

    For example, suppose that you have the foreign key FKEY defined in data set MYLIB.MYOWN and that FKEY is linked to a primary key in data set MAINLIB.MAIN. If the integrity constraint is inactivated by a copy or move operation, you can reactivate the integrity constraint by using the following code:

     proc datasets library=mylib;     modify myown;     ic reactivate fkey references mainlib;  run; 

INDEX CENTILES

Updates centiles statistics for indexed variables.

Restriction: Must be in a MODIFY RUN group

See also: Understanding SAS Indexes in SAS Language Reference: Concepts

INDEX CENTILES index(s)

  • </ <REFRESH>

    <UPDATECENTILES= ALWAYSNEVER integer >>;

Required Arguments

index(s)

  • names one or more indexes.

Options

REFRESH

  • updates centiles immediately, regardless of the value of UPDATECENTILES.

UPDATECENTILES=ALWAYSNEVER integer

  • specifies when centiles are to be updated. It is not practical to update centiles after every data set update. Therefore, you can specify as the value of UPDATECENTILES the percent of the data values that can be changed before centiles for the indexed variables are updated.

    • Valid values for UPDATECENTILES are

  • ALWAYS0

    • updates centiles when the data set is closed if any changes have been made to the data set index.

  • NEVER101

    • does not update centiles.

  • integer

  • is the percent of values for the indexed variable that can be updated before centiles are refreshed.

    Alias: UPDCEN

    Default 5 (percent)

INDEX CREATE Statement

Creates simple or composite indexes for the SAS data set specified in the MODIFY statement.

Restriction: Must be in a MODIFY RUN group

See also: "Understanding SAS Indexes" in SAS Language Reference: Concepts

Featured in: Example 3 on page 378

INDEX CREATE index-specification(s)

  • </ <NOMISS>

    <UNIQUE>

    <UPDATECENTILES= ALWAYSNEVER integer >>;

Required Arguments

index-specification(s)

  • can be one or both of the following forms:

  • variable

    • creates a simple index on the specified variable.

  • index=(variables)

    • creates a composite index. The name you specify for index is the name of the composite index. It must be a valid SAS name and cannot be the same as any variable name or any other composite index name. You must specify at least two variables.

  • Note: The index name must follow the same rules as a SAS variable name, including avoiding the use of reserved names for automatic variables, such as _N_, and special variable list names, such as _ALL_. For more information, refer to Rules for Words and Names in the SAS Language in SAS Language Reference: Concepts .

Options

NOMISS

  • excludes from the index all observations with missing values for all index variables.

    When you create an index with the NOMISS option, SAS uses the index only for WHERE processing and only when missing values fail to satisfy the WHERE expression. For example, if you use the following WHERE statement, SAS does not use the index, because missing values satisfy the WHERE expression:

     where dept ne '01'; 

    Refer to SAS Language Reference: Concepts .

    Note: BY-group processing ignores indexes that are created with the NOMISS option.

    Featured in: Example 3 on page 378

UNIQUE

  • specifies that the combination of values of the index variables must be unique. If you specify UNIQUE and multiple observations have the same values for the index variables, the index is not created.

    Featured in: Example 3 on page 378

UPDATECENTILES=ALWAYSNEVER integer

  • specifies when centiles are to be updated. It is not practical to update centiles after every data set update. Therefore, you can specify the percent of the data values that can be changed before centiles for the indexed variables are updated. Valid values for UPDATECENTILES are as follows:

    ALWAYS0

    • updates centiles when the data set is closed if any changes have been made to the data set index.

  • NEVER101

    • does not update centiles.

  • integer

    • specifies the percent of values for the indexed variable that can be updated before centiles are refreshed.

  • Alias: UPDCEN

    Default: 5% (percent)

INDEX DELETE Statement

Deletes one or more indexes associated with the SAS data set specified in the MODIFY statement.

Restriction: Must appear in a MODIFY RUN group

INDEX DELETE index(s) _ALL_;

Required Arguments

index(s)

  • names one or more indexes to delete. The index(es) must be for variables in the SAS data set that is named in the preceding MODIFY statement. You can delete both simple and composite indexes.

_ALL_

  • deletes all indexes, except for indexes that are owned by an integrity constraint. When an index is created, it is marked as owned by the user, by an integrity constraint, or by both. If an index is owned by both a user and an integrity constraint, the index is not deleted until both an IC DELETE statement and an INDEX DELETE statement are processed.

Note: You can use the CONTENTS statement to produce a list of all indexes for a data set.

INFORMAT Statement

Permanently assigns, changes, and removes variable informats in the data set specified in the MODIFY statement.

Restriction: Must appear in a MODIFY RUN group

Featured in: Example 3 on page 378

INFORMAT variable-list-1 < informat-1 >

  • < variable-list-n < informat-n >>;

Required Arguments

variable-list

  • specifies one or more variables whose informats you want to assign, change, or remove. If you want to disassociate an informat with a variable, list the variable last in the list with no informat following. For example:

     informat a b 2. x1-x3 4.1 c; 

Options

informat

  • specifies an informat for the variables immediately preceding it in the statement. If you do not specify an informat, the INFORMAT statement removes any existing informats for the variables in variable-list .

Note: You can use shortcut methods for specifying variables, such as the keywords _NUMERIC, _CHARACTER_, and _ALL_. See Shortcuts for Specifying Lists of Variable Names on page 24 for more information.

LABEL Statement

Assigns, changes, and removes variable labels for the SAS data set specified in the MODIFY statement.

Restriction: Must appear in a MODIFY RUN group

Featured in: Example 3 on page 378

LABEL variable-1 =< label-1 >

  • < variable-n =< label-n >>;

Required Arguments

variable=< label >

  • assigns a label to a variable. If a single quotation mark appears in the label, write it as two single quotation marks in the LABEL statement. Specifying variable= or variable = removes the current label.

    Range: 1-256 characters

MODIFY Statement

Changes the attributes of a SAS file and, through the use of subordinate statements, the attributes of variables in the SAS file.

Featured in: Example 3 on page 378

MODIFY SAS-file <( option(s) )>

  • </ <CORRECTENCODING= encoding-value >

    <DTC= SAS-date-time >

    <GENNUM= integer >

    <MEMTYPE= mtype >>;

To do this

Use this option

Restrict processing to a certain type of SAS file

MEMTYPE=

Specify attributes

 

Change the character-set encoding

CORRECTENCODING=

 

Specify a creation date and time

DTC=

 

Assign or change a data set label

LABEL=

 

Specify how the data are currently sorted

SORTEDBY=

 

Assign or change a special data set type

TYPE=

Modify passwords

 

Modify an alter password

ALTER=

 

Modify a read, write, or alter password

PW=

 

Modify a read password

READ=

 

Modify a write password

WRITE=

Modify generation groups

 

Modify the maximum number of versions for a generation group

GENMAX=

 

Modify a historical version

GENNUM=

Required Arguments

SAS-file

  • specifies a SAS file that exists in the procedure input library.

Options

ALTER= password-modification

  • assigns, changes, or removes an alter password for the SAS file named in the MODIFY statement. password-modification is one of the following:

    • new-password

    • old-password / new-password

    • / new-password

    • old-password /

    • /

  • See also: Manipulating Passwords on page 347

CORRECTENCODING= encoding-value

  • enables you to change the encoding indicator, which is recorded in the file s descriptor information, in order to match the actual encoding of the file s data.

  • See: The CORRECTENCODING= Option on the MODIFY Statement of the DATASETS Procedure in SAS National Language Support (NLS): User s Guide

DTC= SAS-date-time

  • specifies a date and time to substitute for the date and time stamp placed on a SAS file at the time of creation. You cannot use this option in parentheses after the name of each SAS file; you must specify DTC= after a forward slash. For example:

     modify mydata / dtc='03MAR00:12:01:00'dt; 
  • Tip: Use DTC= to alter a SAS file s creation date and time prior to using the DATECOPY option in the CIMPORT procedure, COPY procedure, CPORT procedure, SORT procedure, and the COPY statement in the DATASETS procedure.

  • Restriction: A SAS file s creation date and time cannot be set later than the date and time the file was actually created.

  • Restriction: DTC= cannot be used with encrypted files or sequential files.

  • Restriction: DTC= can be used only when the resulting SAS file uses the V8 or V9 engine.

GENMAX= number-of-generations

  • specifies the maximum number of versions. You can use this option either in parentheses after the name of each SAS file or after a forward slash.

  • Range: 0 to 1,000

  • Default:

GENNUM= integer

  • restricts processing for generation data sets. You can specify GENNUM= either in parentheses after the name of each SAS file or after a forward slash. Valid value is integer , which is a number that references a specific version from a generation group. Specifying a positive number is an absolute reference to a specific generation number that is appended to a data set s name; that is, gennum=2 specifies MYDATA#002.

  • Specifying a negative number is a relative reference to a historical version in relation to the base version, from the youngest to the oldest; that is, gennum= ˆ’ 1 refers to the youngest historical version. Specifying 0, which is the default, refers to the base version.

  • See also: Understanding Generation Data Sets in SAS Language Reference: Concepts

LABEL= data-set-label

  • assigns, changes, or removes a data set label for the SAS data set named in the MODIFY statement. If a single quotation mark appears in the label, write it as two single quotation marks. LABEL= or LABEL= removes the current label.

  • Range: 1-40 characters

  • Featured in: Example 3 on page 378

MEMTYPE= mtype

  • restricts processing to one member type. You cannot specify MEMTYPE= in parentheses after the name of each SAS file; you must specify MEMTYPE= after a forward slash.

  • Aliases: MTYPE= and MT=

  • Default: If you do not specify the MEMTYPE= option in the PROC DATASETS statement or in the MODIFY statement, the default is MEMTYPE=DATA.

PW= password-modification

  • assigns, changes, or removes a read, write, or alter password for the SAS file named in the MODIFY statement. password-modification is one of the following:

    • new-password

    • old-password / new-password

    • / new-password

    • old-password /

    • /

  • See also: Manipulating Passwords on page 347

READ= password-modification

  • assigns, changes, or removes a read password for the SAS file named in the MODIFY statement. password-modification is one of the following:

    • new-password

    • old-password / new-password

    • old-password /

    • / new-password

    • /

  • See also: Manipulating Passwords on page 347

  • Featured in: Example 3 on page 378

SORTEDBY= sort-information

  • specifies how the data are currently sorted. SAS stores the sort information with the file but does not verify that the data are sorted the way you indicate . sort-information can be one of the following:

  • by-clause </ collate -name >

    • indicates how the data are currently sorted. Values for by-clause are the variables and options you can use in a BY statement in a PROC SORT step. collate-name names the collating sequence used for the sort. By default, the collating sequence is that of your host operating environment.

  • _NULL_

    • removes any existing sort information.

  • Restriction: The data must be sorted in the order that you specify. If the data is not in the specified order, SAS will not sort it for you.

  • Featured in: Example 3 on page 378

TYPE= special-type

  • assigns or changes the special data set type of a SAS data set. SAS does not verify

    • the SAS data set type you specify in the TYPE= option (except to check if it has a length of eight or fewer characters).

    • that the SAS data set s structure is appropriate for the type you have designated.

  • Note: Do not confuse the TYPE= option with the MEMTYPE= option. The TYPE= option specifies a type of special SAS data set. The MEMTYPE= option specifies one or more types of SAS files in a SAS data library.

  • Tip: Most SAS data sets have no special type. However, certain SAS procedures, like the CORR procedure, can create a number of special SAS data sets. In addition, SAS/STAT software and SAS/EIS software support special data set types.

WRITE= password-modification

  • assigns, changes, or removes a write password for the SAS file named in the MODIFY statement. password-modification is one of the following:

    • new-password

    • old-password / new-password

    • / new-password

    • /

    • old-password /

  • See also: Manipulating Passwords on page 347

Manipulating Passwords

In order to assign, change, or remove a password, you must specify the password for the highest level of protection that currently exists on that file.

Assigning Passwords
 /* assigns a password to an unprotected file */  modify colors (pw=green);  /* assigns an alter password to an already read-protected SAS data set */  modify colors (read=green alter=red); 
Changing Passwords
 /* changes the write password from YELLOW to BROWN */  modify cars (write=yellow/brown);  /* uses alter access to change unknown read password to BLUE */  modify colors (read=/blue alter=red); 
Removing Passwords
 /* removes the alter password RED from STATES */  modify states (alter=red/);  /* uses alter access to remove the read password */  modify zoology (read=green/ alter=red);  /* uses PW= as an alias for either WRITE= or ALTER= to remove unknown     read password */  modify biology (read=/ pw=red); 

Working with Generation Groups

Changing the Number of Generations
 /* changes the number of generations on data set A to 99 */  modify A (genmax=99); 
Removing Passwords
 /* removes the alter password RED from STATES#002 */  modify states (alter=red/) / gennum=2; 

RENAME Statement

Renames variables in the SAS data set specified in the MODIFY statement.

Restriction: Must appear in a MODIFY RUN group

Featured in: Example 3 on page 378

RENAME old-name-1=new-name-1

  • < old-name-n=new-name-n >;

Required Arguments

old-name=new-name

  • changes the name of a variable in the data set specified in the MODIFY statement. old-name must be a variable that already exists in the data set. new-name cannot be the name of a variable that already exists in the data set or the name of an index, and the new name must be a valid SAS name. See Rules for SAS Variable Names in SAS Language Reference: Concepts .

Details

  • If old-name does not exist in the SAS data set or new-name already exists, PROC DATASETS stops processing the RUN group containing the RENAME statement and issues an error message.

  • When you use the RENAME statement to change the name of a variable for which there is a simple index, the statement also renames the index.

  • If the variable that you are renaming is used in a composite index, the composite index automatically references the new variable name. However, if you attempt to rename a variable to a name that has already been used for a composite index, you receive an error message.

REPAIR Statement

Attempts to restore damaged SAS data sets or catalogs to a usable condition.

REPAIR SAS-file(s)

  • </ <ALTER= alter-password >

  • <GENNUM= integer >

  • <MEMTYPE= mtype >>;

Required Arguments

SAS-file(s)

  • specifies one or more SAS data sets or catalogs in the procedure input library.

Options

ALTER= alter-password

  • provides the alter password for any alter-protected SAS files that are named in the REPAIR statement. You can use the option either in parentheses after the name of each SAS file or after a forward slash.

  • See also: Using Passwords with the DATASETS Procedure on page 355

GENNUM= integer

  • restricts processing for generation data sets. You can use the option either in parentheses after the name of each SAS file or after a forward slash. Valid value is integer , which is a number that references a specific version from a generation group. Specifying a positive number is an absolute reference to a specific generation number that is appended to a data set s name; that is, gennum=2 specifies MYDATA#002. Specifying a negative number is a relative reference to a historical version in relation to the base version, from the youngest to the oldest; that is, gennum=-1 refers to the youngest historical version. Specifying 0, which is the default, refers to the base version.

  • See also: Restricting Processing for Generation Data Sets on page 358

  • See also: Understanding Generation Data Sets in SAS Language Reference: Concepts

MEMTYPE= mtype

  • restricts processing to one member type.

  • Aliases: MT=, MTYPE=

  • Default: If you do not specify the MEMTYPE= option in the PROC DATASETS statement or in the REPAIR statement, the default is MEMTYPE=ALL.

  • See also: Restricting Member Types for Processing on page 356

Details

The most common situations that require the REPAIR statement are as follows:

  • A system failure occurs while you are updating a SAS data set or catalog.

  • The device on which a SAS data set or an associated index resides is damaged. In this case, you can restore the damaged data set or index from a backup device, but the data set and index no longer match.

  • The disk that stores the SAS data set or catalog becomes full before the file is completely written to disk. You may need to free some disk space. PROC DATASETS requires free space when repairing SAS data sets with indexes and when repairing SAS catalogs.

  • An I/O error occurs while you are writing a SAS data set or catalog entry.

When you use the REPAIR statement for SAS data sets, it recreates all indexes for the data set. It also attempts to restore the data set to a usable condition, but the restored data set may not include the last several updates that occurred before the system failed. You cannot use the REPAIR statement to recreate indexes that were destroyed by using the FORCE option in a PROC SORT step.

When you use the REPAIR statement for a catalog, you receive a message stating whether the REPAIR statement restored the entry. If the entire catalog is potentially damaged, the REPAIR statement attempts to restore all the entries in the catalog. If only a single entry is potentially damaged, for example when a single entry is being updated and a disk-full condition occurs, on most systems only the entry that is open when the problem occurs is potentially damaged. In this case, the REPAIR statement attempts to repair only that entry. Some entries within the restored catalog may not include the last updates that occurred before a system crash or an I/O error. The REPAIR statement issues warning messages for entries that may have truncated data.

To repair a damaged catalog, the version of SAS that you use must be able to update the catalog. Whether a SAS version can update a catalog (or just read it) is determined by the SAS version that created the catalog:

  • A damaged Version 6 catalog can be repaired with Version 6 only.

  • A damaged Version 8 catalog can be repaired with either Version 8 or SAS System 9, but not with Version 6.

  • A damaged SAS System 9 catalog can be repaired with SAS System 9 only.

If the REPAIR operation is not successful, try to restore the SAS data set or catalog from your system s backup files.

If you issue a REPAIR statement for a SAS file that does not exist in the specified library, PROC DATASETS stops processing the run group that contains the REPAIR statement, and issues an error message. To override this behavior and continue processing, use the NOWARN option in the PROC DATASETS statement.

If you are using Cross-Environment Data Access (CEDA) to process a damaged foreign SAS data set, CEDA cannot repair it. CEDA does not support update processing, which is required in order to repair a damaged data set. To repair the foreign file, you must move it back to its native environment. Note that observations may be lost during the repair process. For more information about CEDA, refer to Processing Data Using Cross-Environment Data Access in SAS Language Reference: Concepts .

SAVE Statement

Deletes all the SAS files in a library except the ones listed in the SAVE statement.

Featured in: Example 2 on page 377

SAVE SAS-file(s) </ MEMTYPE= mtype >;

Required Arguments

SAS-file(s)

  • specifies one or more SAS files that you do not want to delete from the SAS data library.

Options

MEMTYPE= mtype

  • restricts processing to one member type. You can use the option either in parentheses after the name of each SAS file or after a forward slash.

  • Aliases: MTYPE= and MT=

  • Default: If you do not specify the MEMTYPE= option in the PROC DATASETS statement or in the SAVE statement, the default is MEMTYPE=ALL.

  • See also: Restricting Member Types for Processing on page 356

  • Featured in: Example 2 on page 377

Details

  • If one of the SAS files in SAS-file does not exist in the procedure input library, PROC DATASETS stops processing the RUN group containing the SAVE statement and issues an error message. To override this behavior, specify the NOWARN option in the PROC DATASETS statement.

  • When the SAVE statement deletes SAS data sets, it also deletes any indexes associated with those data sets.

  • CAUTION:

    • SAS immediately deletes libraries and library members when you submit a RUN group. You are not asked to verify the delete operation before it begins. Because the SAVE statement deletes many SAS files in one operation, be sure that you understand how the MEMTYPE= option affects which types of SAS files are saved and which types are deleted.

  • When you use the SAVE statement with generation groups, the SAVE statement treats the base version and all historical versions as a unit. You cannot save a specific version.

SELECT Statement

Selects SAS files for copying.

Restriction: Must follow a COPY statement

Restriction: Cannot appear with an EXCLUDE statement in the same COPY step

Featured in: Example 1 on page 372

SELECT SAS-file(s)

  • </ <ALTER= alter-password >

  • <MEMTYPE= mtype >>;

Required Arguments

SAS-file(s)

  • specifies one or more SAS files that you want to copy. All of the SAS files that you name must be in the data library that is referenced by the libref named in the IN= option in the COPY statement. If the SAS files have generation groups, the SELECT statement allows only selection of the base versions.

Options

ALTER= alter-password

  • provides the alter password for any alter-protected SAS files that you are moving from one data library to another. Because you are moving and thus deleting a SAS file from a SAS data library, you need alter access. You can use the option either in parentheses after the name of each SAS file or after a forward slash.

  • See also: Using Passwords with the DATASETS Procedure on page 355

MEMTYPE= mtype

  • restricts processing to one member type. You can use the option either in parentheses after the name of each SAS file or after a forward slash.

  • Aliases: MTYPE= and MT=

  • Default: If you do not specify the MEMTYPE= option in the PROC DATASETS statement, in the COPY statement, or in the SELECT statement, the default is MEMTYPE=ALL.

  • See also: Specifying Member Types When Copying or Moving SAS Files on page 327

  • See also: Restricting Member Types for Processing on page 356

  • Featured in: Example 1 on page 372

Selecting Many Like-Named Files

You can use shortcuts for listing many SAS files in the SELECT statement. For more information, see Shortcuts for Specifying Lists of Variable Names on page 24.




Base SAS 9.1.3 Procedures Guide (Vol. 1)
Base SAS 9.1 Procedures Guide, Volumes 1, 2, 3 and 4
ISBN: 1590472047
EAN: 2147483647
Year: 2004
Pages: 260

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