Proc Pwencode :

To convert password into Encrypted mode.
Syntax:-
PROC PWENCODE IN=’password’ <OUT=fileref> <METHOD=encoding-method>;
Options:-
IN=’password’
Specifies the password to encode. The password can contain up to a maximum of 512 characters, which include alphanumeric characters, spaces, and special characters. If the password contains embedded single or double quotation marks, use the standard SAS rules for quoting character constants
Proc pwencode in=’sasadm@123′;
Run;
{sas002}835DA5352D5AE01B0E6239C33E3C791E4FA5AD34

OUT=fileref
Specifies a fileref to which the output string is to be written. If the OUT= option is not specified, the output string is written to the SAS log.

Filename Krishna “D:\mysas\Sample.txt”;
Proc pwencode in=’sasadm@123′ out=Krishna;
Run;

METHOD=encoding-method
Specifies the encoding method. Here are the supported values for encoding-method:
Encrypted password contains starting letters as {sas002} or {sas001} or {sas003}
sas001
Uses 64-bit key to encode passwords.
sas002
Uses a 32-bit key to encode passwords. This is the default.
sas003
Uses a 256-bit key to encode passwords. AES (Advanced Encryption Standard), which is supported in SAS/SECURE

Examples:-
PROC SQL;
CONNECT TO ORACLE (USER=SCOTT PASSWORD=TIGER);
CREATE TABLE DS1 AS
SELECT * FROM CONNECTION TO ORACLE
(
SELECT * FROM DEPT
);
DISCONNECT FROM ORACLE;
QUIT;
PROC PWENCODE IN=’TIGER’;
RUN;
PROC SQL;
CONNECT TO ORACLE (USER=SCOTT PASSWORD='{SAS002}F77E0C345A42C6A753443DCE’);
CREATE TABLE DS1 AS
SELECT * FROM CONNECTION TO ORACLE
(
SELECT * FROM DEPT
);
DISCONNECT FROM ORACLE;
QUIT;
In realtime usernames and passwords will provide by client. Generally we can’t specify our direct passwords in program, why because when others know our password’s there is a chance to misuse the passwords. To avoid this problem we need to encrypt out passwords using PROC PWENCODE that encrypted password we need to apply in program. This encrypted password having only reading permissions so others can’t misuse.
Real time example:-
PROC SQL;
CONNECT TO ORACLE AS KRISHNA (USER=MISREP PASSWORD=”{SAS001}QZBYCDBYX3QZ” PATH=SRMPROD );
CREATE TABLE ATG_1 AS
SELECT * FROM CONNECTION TO KRISHNA
(SELECT SUM(CASE WHEN PRODUCT_TYPE IN (‘B’,’C’,’S’) THEN TOTAL_TRADE_VALUE ELSE 0 END)/10000000 E_CASH,
SUM(CASE WHEN PRODUCT_TYPE IN (‘M’,’T’,’A’,’E’) THEN TOTAL_TRADE_VALUE ELSE 0 END)/10000000 E_MARGIN,
SUM(CASE WHEN PRODUCT_TYPE IN (‘F’,’O’,’P’) THEN TOTAL_TRADE_VALUE ELSE 0 END)/10000000 E_DER,
SUM(TOTAL_TRADE_VALUE)/10000000 E_TOTAL
FROM MISREP.CUSTOMER_GROUP,MISREP.CLM_DAY_SUMM
WHERE TRADE_DATE =TRUNC(SYSDATE-1)
AND MATCH_ACCNT_NO = CLM_MTCH_ACCNT
AND TEAM =’ATG’
);
DISCONNECT FROM KRISHNA;
QUIT;