Assigning Passwords

Syntax

To set a password, first specify a SAS data set in one of the following:
  • a DATA statement
  • the MODIFY statement of the DATASETS procedure
  • an OUT= option in some procedures
  • the CREATE VIEW statement in PROC SQL
  • the ToolBox
Then assign one or more password types to the data set. The data set might already exist, or the data set might be one that you create. The following is an example of syntax:
password-type=password ... password-type=password>)
where password is a valid eight-character SAS name and password-type can be one of the following SAS data set options:
  • ALTER=
  • PW=
  • READ=
  • WRITE=
CAUTION:
Keep a record of any passwords that you assign!
If you forget or do not know the password, you cannot get the password from SAS.

Assigning a Password with a DATA Step

You can use data set options to assign passwords to unprotected members in the DATA step when you create a new SAS data file.
This example prevents deletion or modification of the data set without a password.
/* assign a write and an alter password to MYLIB.STUDENTS */
data mylib.students(write=yellow alter=red);
   input name $ sex $ age;
   datalines;
Amy f 25
… more data lines …
;
This example prevents reading or deleting a stored program without a password and also prevents changing the source program.
/* assign a read and an alter password to the SAS view ROSTER */
data mylib.roster(read=green alter=red) / view=mylib.roster;
   set mylib.students;
run;
libname stored 'SAS-library-2';

/* assign a read and alter password to the program file SOURCE */
data mylib.schedule / pgm=stored.source(read=green alter=red);
   … DATA step statements …
run;
Note: When you replace a SAS data set that is alter-protected, the new data set inherits the Alter password. To change the Alter password for the new data set, use the MODIFY statement in the DATASETS procedure.

Assigning a Password to an Existing Data Set

You can use the MODIFY statement in the DATASETS procedure to assign passwords to unprotected members if the SAS data file already exists.
/* assign an alter password to STUDENTS */
proc datasets library=mylib;
   modify students(alter=red);
run;

Assigning a Password with a Procedure

You can assign a password after an OUT= data set specification in some procedures.
/* assign a write and an alter password to SCORE */
proc sort data=mylib.math 
   out=mylib.score(write=yellow alter=red);
   by number;
run;
You can assign a password in a CREATE TABLE or a CREATE VIEW statement in PROC SQL.
/* assign an alter password to the SAS view BDAY */
proc sql;
   create view mylib.bday(alter=red) as
     query-expression;

Assigning a Password with the SAS Windowing Environment

You can create or change passwords for any data file using the Password Window in the SAS windowing environment. To invoke the Password Window from the ToolBox, use the global command SETPASSWORD followed by the filename. This opens the password window for the specified data file.

Assigning a Password outside of SAS

A SAS password does not control access to a SAS file beyond the SAS system. You should use the operating system-supplied utilities and file-system security controls in order to control access to SAS files outside of SAS.