BookmarkSubscribeRSS Feed
renjithr
Quartz | Level 8

Hi All,

 

I am trying to figure out how I can create temporary tables/volatile tables in SAS - ORACLE pass-thru sql.

 

Below is my code, but it is throwing an error saying 

ERROR: ORACLE execute error: ORA-00933: SQL command not properly ended.

PROC SQL;
	CONNECT TO ORACLE  (PATH="CS.WORLD" USER="&uid_db2." PASSWORD="&pwd_db2.");
	EXECUTE ( 
		CREATE GLOBAL TEMPORARY TABLE QUERY_FOR_INSTN_ENCTR  as 
		 select * from connection to oracle
			(
   SELECT t1.RGN_CD, 
          t1.ENCTR_SK, 
          t1.ENCTR_SRC_SYS_CD, 
          t1.CORR_MRN_PLS_NB, 
          t1.LOC_IK, 
          t1.CARE_SETNG_IK, 
          t1.PTNT_RSDNC_ZIP_IK AS PTNT_RSDNC_ZIP_IK1, 
          t1.ENCTR_STRT_TS, 
          t1.ENCTR_END_TS, 
          t1.DRG_IK, 
          t1.PTNT_RSDNC_ZIP_IK, 
          t1.PRNCPL_ICD_DIAG_IK, 
          t1.PRMY_ATND_PRVDR_IK, 
          t1.MDC_IK, 
          t1.ADMT_PRVDR_IK, 
          t1.PRNCPL_ICD_PROC_IK, 
          t1.PRNCPL_PROC_PRVDR_IK, 
          t1.PTNT_AGE_YR_NB, 
          t1.PTNT_BRTH_DT, 
          t1.PTNT_GNDR_CD, 
          t1.INPAT_LOS_DAY_CT, 
          t1.TTL_LOS_DAY_CT
      FROM IA_V.INSTN_ENCTR t1
      WHERE t1.RGN_CD = '08' AND t1.ENCTR_STRT_DT BETWEEN '1Jan2016:0:0:0'dt AND '31Mar2017:0:0:0'dt AND 
           t1.ENCTR_SRC_SYS_CD = 'C' AND t1.PTNT_AGE_YR_NB < 18
		   ) on commit preserve rows) by oracle;
	

	Create table STEP150 as
		SELECT * FROM CONNECTION TO ORACLE
			(
		Select *
			from QUERY_FOR_INSTN_ENCTR
			);
			disconnect from oracle;
QUIT; 

I am not sure my code/syntax is correct. Please advice.

 

Thanks

3 REPLIES 3
SASKiwi
PROC Star
PROC SQL;
	CONNECT TO ORACLE  (PATH="CS.WORLD" USER="&uid_db2." PASSWORD="&pwd_db2.");
	EXECUTE ( 
		CREATE GLOBAL TEMPORARY TABLE QUERY_FOR_INSTN_ENCTR  as 
		 
   SELECT t1.RGN_CD, 
          t1.ENCTR_SK, 
          t1.ENCTR_SRC_SYS_CD, 
          t1.CORR_MRN_PLS_NB, 
          t1.LOC_IK, 
          t1.CARE_SETNG_IK, 
          t1.PTNT_RSDNC_ZIP_IK AS PTNT_RSDNC_ZIP_IK1, 
          t1.ENCTR_STRT_TS, 
          t1.ENCTR_END_TS, 
          t1.DRG_IK, 
          t1.PTNT_RSDNC_ZIP_IK, 
          t1.PRNCPL_ICD_DIAG_IK, 
          t1.PRMY_ATND_PRVDR_IK, 
          t1.MDC_IK, 
          t1.ADMT_PRVDR_IK, 
          t1.PRNCPL_ICD_PROC_IK, 
          t1.PRNCPL_PROC_PRVDR_IK, 
          t1.PTNT_AGE_YR_NB, 
          t1.PTNT_BRTH_DT, 
          t1.PTNT_GNDR_CD, 
          t1.INPAT_LOS_DAY_CT, 
          t1.TTL_LOS_DAY_CT
      FROM IA_V.INSTN_ENCTR t1
      WHERE t1.RGN_CD = '08' AND t1.ENCTR_STRT_DT BETWEEN '1Jan2016:0:0:0'dt AND '31Mar2017:0:0:0'dt AND 
           t1.ENCTR_SRC_SYS_CD = 'C' AND t1.PTNT_AGE_YR_NB < 18;
		    on commit preserve rows;) by oracle;
	

	Create table STEP150 as
		SELECT * FROM CONNECTION TO ORACLE
			(
		Select *
			from QUERY_FOR_INSTN_ENCTR
			);
			disconnect from oracle;
QUIT; 
renjithr
Quartz | Level 8

Thank you, I am still getting an error.

 

ERROR: ORACLE execute error: ORA-00905: missing keyword.

Reeza
Super User

I'm not that familiar with Oracle, but isn't this SAS code, not Oracle code?

 

t1.ENCTR_STRT_DT BETWEEN '1Jan2016:0:0:0'dt AND '31Mar2017:0:0:0'dt

It has to be Oracle SQL and date formats. 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 4431 views
  • 1 like
  • 3 in conversation