BookmarkSubscribeRSS Feed
TheNovice
Quartz | Level 8

I have 2 tables with a large number of records (100k+).

 

Table B is the base that i have extracted and need to join to table B. 

I have to pull invoices for records for the previous 3 months. Where i am getting lost is on how to account for pulling records for the previous year if the date i have is for Jan.

 

I need to pull records where bill month falls in the 3 months before the sus month. Meaning 3 records.

 

I have tried this but get no records... and i realize that it won't help me if the Sus_month value is 1 . The months being from 1 - 12.

and I have no idea on how to account for cases where it will need to pull from 2018


PROC SQL;
 CONNECT TO ORACLE (USER=&NAME  PW=&PASS  PATH=EXAODIN);
 CREATE TABLE CHARGE AS
  SELECT B.*,A.* FROM CONNECTION TO ORACLE
  (SELECT ID,SUB,BILL_YEAR,BILL_MONTH
   FROM  OS.CHARGE
    ) A INNER JOIN TEST2 B
    ON B.ID= A.ID
    WHERE  A.BILL_MONTH BETWEEN (B.SUS_MONTH -3) AND (B.SUS_MONTH -1)
    
 ;
 DISCONNECT FROM ORACLE;
QUIT;

1 REPLY 1
Tom
Super User Tom
Super User

It looks like you are tying to join the Oracle table OS.CHARGE to the SAS dataset WORK.TEST2.

If OS.CHARGE is large then you will probably need to upload a copy of TEST2 into Oracle in order to prevent SAS from pulling ALL of OS.CHARGE over to SAS.

 

If you are getting syntax errors then please show the lines from the SAS log.  Make sure to paste in the lines of text from the log (not a Polaroid of your screen) using the Insert Code button on the editor so that the formatting is preserved. 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 1 reply
  • 239 views
  • 0 likes
  • 2 in conversation