ENCRYPT= Data Set Option

Specifies whether to encrypt an output SAS data set.

Valid in: DATA step and PROC steps
Category: Data Set Control
Default: ENCRYPT=NO
Restriction: Use with output data sets only.

Syntax

ENCRYPT=AES | NO | YES

Syntax Description

AES

encrypts the file by using the AES (Advanced Encryption Standard) algorithm. AES provides enhanced encryption by using SAS/SECURE software, which is included with Base SAS software. You must specify the ENCRYPTKEY= data set option when you are using ENCRYPT=AES. For more information, see ENCRYPTKEY= Data Set Option.

Restriction The tape engine does not support ENCRYPT=AES. Use ENCRYPT=YES for tape engine encryption.
CAUTION:
Record all ENCRYPTKEY= values when you are using ENCRYPT=AES.
If you forget to record the ENCRYPTKEY= value, you lose your data. SAS cannot assist you in recovering the ENCRYPTKEY= value. The following note is written to the log:
Note: If you lose or forget the ENCRYPTKEY= value, there will 
be no way to open the file or recover the data.

NO

does not encrypt the file.

YES

encrypts the file by using the SAS Proprietary algorithm. This encryption uses passwords that are stored in the data set. At a minimum, you must specify the READ= data set option or the PW= data set option at the same time that you specify ENCRYPT=YES. Because the encryption method uses passwords, you cannot change any password on an encrypted data set without re-creating the data set.

CAUTION:
Record all passwords when you are using ENCRYPT=YES.
If you forget the passwords, you cannot reset them without assistance from SAS. This is a time-consuming and resource-intensive process.

Details

To use ENCRYPT=YES data files, you must have SAS 6.11 or later. When you use ENCRYPT=YES, these rules apply:
  • To copy an encrypted data file, the output engine must support the encryption.
  • If the data file is encrypted, all associated indexes are also encrypted.
  • You cannot use PROC CPORT on SASProprietary encrypted data files.
Note: SAS views do not contain data. Therefore, encryption is not necessary.
To use encrypted AES data files, you must use SAS 9.4 or later and SAS/SECURE software. In addition, when you use ENCRYPT=AES, these rules apply:
  • You must use the ENCRYPTKEY= data set option when creating a data set with AES encryption.
  • To copy an encrypted AES data file, the output engine must support AES encryption.
  • In Base SAS, data files with referential integrity constraints can use AES encryption. All primary key and foreign key data files must use the same encryption key that opens all referencing foreign key and primary key data files.
You cannot change the ENCRYPTKEY= value on an AES-encrypted data file without re-creating the data file.
Note: Encryption requires approximately the same amount of CPU resources as compression.

Examples

Example 1: Using the ENCRYPT=YES Option

The following example encrypts the data set by using the SAS Proprietary algorithm:
libname mylib "c:\mylib";

data mylib.salary(encrypt=yes read=green);
   input name $ yrsal bonuspct;
   datalines;
Muriel    34567  3.2
Bjorn     74644  2.5
Freda     38755  4.1
Benny     29855  3.5
Agnetha   70998  4.1
;
To use this data set, specify the READ= password:
proc contents data=mylib.salary(read=green);
run;
ENCRYPT=YES
ENCRYPT=YES Output

Example 2: Using the ENCRYPT=AES Option

libname mylib "c:\mylib";

data mylib.salary(encrypt=aes encryptkey=green);
   input name $ yrsal bonuspct;
   datalines;
Muriel    34567  3.2
Bjorn     74644  2.5
Freda     38755  4.1
Benny     29855  3.5
Agnetha   70998  4.1
;
The following example encrypts the data set by using the AES algorithm:
proc contents data=mylib.salary(encryptkey=green);
run;
ENCRYPT=AES
ENCRYPT=AES Output