DATASETS Procedure

MODIFY Statement

Changes the attributes of a SAS file and, through the use of subordinate statements, the attributes of variables in the SAS file.
Restriction: You cannot change the length of a variable using the LENGTH= option on an ATTRIB statement.
Modifying SAS Data Sets

Syntax

Summary of Optional Arguments

restricts processing to a certain type of SAS file.
Modify generation groups
modifies the maximum number of versions for a generation group.
modifies a historical version.
Modify passwords
modifies an Alter password.
modifies a Read, Write, or Alter password.
modifies a Read password.
modifies a Write password.
Specify data set attributes
changes the character-set encoding.
specifies a creation date and time.
assigns or change a data set label.
specifies how the data are currently sorted.
assigns or changes a special data set type.

Required Argument

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

Optional Arguments

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 /
  • /
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: “CORRECTENCODING= Option” in SAS National Language Support (NLS): Reference 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:
modify mydata / dtc='03MAR00:12:01:00'dt;
Restrictions:A SAS file's creation date and time cannot be set later than the date and time the file was actually created.

DTC= cannot be used with encrypted files or sequential files.

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

Tip:Use DTC= to alter a SAS file's creation date and time before using the DATECOPY option in the COPY procedure, CPORT procedure, SORT procedure, and the COPY statement in the DATASETS procedure.
GENMAX=number-of-generations
specifies the maximum number of versions. Use this option in parentheses after the name of SAS file.
Default:0
Range:0 to 1,000
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:“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 - 256 characters
Restriction:A view label cannot be updated after the label is created.
Tip:To remove all variable labels in a data set, use the ATTRIB statement .
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.
Alias: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 /
  • /
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
  • / new-password
  • old-password /
  • /
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 that 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 indicator.
Restriction:The data must be sorted in the order in which you specify. If the data is not in the specified order, SAS does not sort it for you.
Tip:When using the MODIFY SORTEDBY option, you can also use a numbered range list or colon list. For more information, see Data Set Lists in SAS Language Reference: Concepts.
TYPE=special-type
assigns or changes the special data set type of a SAS data set. SAS does not verify the following:
  • the SAS data set type that 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 that 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 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 /
  • /

Details

Changing Data Set Labels and Variable Labels

The LABEL option can change either the data set label or a variable label within the data set. To change a data set label, use the following syntax:
modify datasetname(label='Label for Data Set');
run; 
You can change one or more variable labels within a data set. To change a variable label within the data set, use the following syntax:
modify datasetname;
    label  variablename='Label for Variable';
run;
For an example of changing both a data set label and a variable label in the same PROC DATASETS, see Modifying SAS Data Sets.

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;