Base SAS 9.1 Procedures Guide, Volumes 1, 2, 3 and 4

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) >;

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

DETAILSNODETAILS

FORCE

GENNUM=ALLHISTREVERT integer

KILL

LIBRARY= libref

MEMTYPE=( mtype(s) )

NODETAILS

NOLIST

NOWARN

PW= password

READ= read-password

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)

Required Arguments

current-name

related-SAS-file(s)

Options

ALTER= alter-password

MEMTYPE= mtype

Details

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

Required Arguments

BASE=< libref. > SAS-data-set

Options

APPENDVER=V6

DATA=< libref. > SAS-data-set

FORCE

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:

CAUTION:

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 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:

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.

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

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

Output 15.2: Warning Message in SAS Log

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.

 

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 )>;

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

Required Arguments and Statements

SAS-file

INITIATE

Options

SAS-password

GENNUM= integer

AUDIT_ALL=NOYES

LOG

USER_VAR variable-1 < variable-n >

SUSPEND

RESUME

TERMINATE

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

Required Arguments

old-name=new-name

Options

ALTER= alter-password

GENNUM=ALL integer

MEMTYPE= mtype

Details

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

DATA= SAS-file-specification

DETAILSNODETAILS

DIRECTORY

FMTLEN

MEMTYPE=( mtype(s) )

NODS

NODETAILS

NOPRINT

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

OUT2= SAS-data-set

SHORT

VARNUM

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

Required Arguments

OUT= libref-1

Options

ALTER= alter-password

CLONENOCLONE

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

DATECOPY

FORCE

IN= libref-2

INDEX=YESNO

MEMTYPE=( mtype(s) )

MOVE

NOCLONE

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:

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:

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

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)

Required Arguments

SAS-file(s)

Options

ALTER= alter-password

GENNUM=ALLHISTREVERT integer

MEMTYPE= mtype

Details

Working with Generation Groups

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

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

Required Arguments

name=other-name

Options

ALTER= alter-password

MEMTYPE= mtype

Details

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)

Options

MEMTYPE= mtype

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 >

Required Arguments

variable-list

Options

format

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

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,

Options

< constraint-name= >

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

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)

_ALL_

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

libref

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)

Required Arguments

index(s)

Options

REFRESH

UPDATECENTILES=ALWAYSNEVER integer

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)

Required Arguments

index-specification(s)

Options

NOMISS

UNIQUE

UPDATECENTILES=ALWAYSNEVER integer

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)

_ALL_

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 >

Required Arguments

variable-list

Options

informat

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 >

Required Arguments

variable=< label >

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) )>

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

Options

ALTER= password-modification

CORRECTENCODING= encoding-value

DTC= SAS-date-time

GENMAX= number-of-generations

GENNUM= integer

LABEL= data-set-label

MEMTYPE= mtype

PW= password-modification

READ= password-modification

SORTEDBY= sort-information

TYPE= special-type

WRITE= password-modification

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

Required Arguments

old-name=new-name

Details

REPAIR Statement

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

REPAIR SAS-file(s)

Required Arguments

SAS-file(s)

Options

ALTER= alter-password

GENNUM= integer

MEMTYPE= mtype

Details

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

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:

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)

Options

MEMTYPE= mtype

Details

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)

Required Arguments

SAS-file(s)

Options

ALTER= alter-password

MEMTYPE= mtype

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.

Категории