This question is similar to mine:
I am querying an Oracle database from SAS, and I am unable to create temporary tables within the Oracle database.
I find proc sql explicit pass-through to be the fastest method for querying the database.
What I want to do is define a macro variable within SAS called PatID, and then passthrough the value for PatID to a bind variable called pat_id_var within Oracle. The following code returns "ERROR: ORACLE execute error: ORA-01008: not all variables bound."
%LET PatID='123456789'; proc sql; CONNECT TO ORACLE(AuthDomain='OracleAuth' PATH= ); execute (DECLARE pat_id_var varchar2(18); begin :pat_id_var := &PatID. ; end; ) by ORACLE; create table work.WANT as select * from connection to oracle ( select PatientID from oradb.PATIENTS where PatientID = :pat_id_var ); disconnect from ORACLE; quit;
My goal is to hide the true value of PatID in both SAS log and Oracle.
The following code does not hide the PatID value when I view the sql statement in Oracle:
%LET PatID='123456789'; proc sql; CONNECT TO ORACLE(AuthDomain='OracleAuth' PATH= ); create table work.WANT as select * from connection to oracle ( select PatientID from oradb.PATIENTS where PatientID = &PatID. ); disconnect from ORACLE; quit;
Thanks for any insight!
What is the business need to hide PATID, given it is in the SAS table you are creating and the Oracle table you are querying. If this column is that sensitive it should be encrypted in Oracle and then you would query on the encrypted value.
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.