Where does the extra semi-colon come from. It's not in the code as posted.
And because I "stumbled" over the code while doing something else here the logic to derive a DB schema name from a SAS library definition (code for SAS libref myora as per your sample code).
proc sql noprint;
select sysvalue into :ora_schema trimmed
from dictionary.libnames
where
libname="%upcase(myora)"
and sysname='Schema/Owner'
;
quit;
proc sql;
connect using myora;
create table want as
select * from connection to myora
(
SELECT *
FROM &ora_schema..fact_ope_form
limit 10000;
)
;
disconnect from myora;
quit;
IF you've got already a SAS library defined that points to your Oracle schema then I'd be using the connect using syntax as it avoids passing explicit connection info in code - especially credentials. If there isn't such a pre-assigned SAS library then ideally use an authentication domain instead of explicit credentials.
If developing explicit pass-through SQL I normally use a two step approach:
1. First develop the DB specific pass-through SQL syntax using a DB client (i.e. SQL Developer).
2. Once DB SQL fully working "wrap" SAS around it.
If you want help discovering the connection details for an existing libref you can use this macro:
https://github.com/sasutils/macros/blob/master/dblibchk.sas
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.
Ready to level-up your skills? Choose your own adventure.