Jan 22, 2012

Encode your passwords in SAS using Proc PWENCODE

The PWENCODE SAS procedure enables you to encode passwords that can be used in place of plain-text passwords in SAS programs that access relational database management systems (RDBMSs), SAS/SHARE servers, and SAS Integrated Object Model (IOM) servers (such as the SAS Metadata Server).

PROC PWENCODE IN=’password’ ;
IN=’password’ 
specifies the password to encode. password can have no more than 512 characters. password can contain letters, numerals, spaces, and special characters
OUT=fileref 
specifies a fileref to which the output string is to be written. If the OUT= option is not specified, then the output string is written to the SAS log.
METHOD=encoding-method 
specifies the encoding method to use. Currently, sas001 is the only supported encoding method and is the default if the METHOD= option is omitted.
When a password is encoded with PROC PWENCODE, the output string includes a tag that identifies the string as having been encoded. An example of a tag is {sas001}. The tag indicates the encoding method. SAS servers and SAS/ACCESS engines recognize the tag and decode the string before using it. Encoding a password enables you to write SAS programs without having to specify a password in plain text.
/* ENCODE the password and Write it to the Log*/
 
proc pwencode in='password';
run;
 
/* ENCODE the password and Save it to the ClipBoard*/
 
filename clip clipbrd;
proc pwencode in='password' out=clip; run;
/* ENCODE the password and Save it to the Text file C:\pass.txt */
 
filename pwfile 'C:\pass.txt';
proc pwencode in='password' out=pwfile; run;
 
/*Use the New password to connect to RDBMS, FTP or anywhere in SAS*/
 
/* Here's an FTP Example 
 
This example creates a file called test.dat in the \remote directory of the unix ftp server for the user ftpuser on the host unixserver:
*/
 
filename create ftp 'test.dat' cd='~'
         host='unixserver'
         user='ftpuser' pass='{sas001}cGFzc3dvcmQ=' recfm=v;
 
data _null_;
   file create;
   do i=1 to 10;
      put i=;
   end;
run;

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.