Previous Page | Next Page

The 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.
Featured in: Modifying SAS Data Sets

MODIFY SAS-file <(option-1 <...option-n>)>
</ <CORRECTENCODING=encoding-value>
<DTC=SAS-date-time>
<GENNUM=integer>
<MEMTYPE=mtype>>;

Action Option
Restrict processing to a certain type of SAS file MEMTYPE=
Specify data set 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
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 the MODIFY Statement of the DATASETS Procedure 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;
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.
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 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 - 256 characters
Featured in: Modifying SAS Data Sets
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.

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

  • /

See also: Manipulating Passwords
Featured in: Modifying SAS Data Sets
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 indicator.

Restriction: The data must be sorted in the order that 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.
Featured in: Modifying SAS Data Sets
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 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 library.  [cautionend]

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

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;

Previous Page | Next Page | Top of Page