Hello SAS Community, I have a scenario where we will need to pull data from multiple databases. Right now we are manually / hard coding through a left join database names that will be created over time. These databases only come into existence once the month end has occurred. i.e. - VCRCM1801 - DB Name VCRCM suffixed with 18 (for 2018), and 01 (for January) VCRCM1802 - DB Name VCRCM suffixed with 18 (for 2018), and 01 (for February) VCRCM1803 - DB Name VCRCM suffixed with 18 (for 2018), and 01 (for March) VCRCM1804 - DB Name VCRCM suffixed with 18 (for 2018), and 01 (for April) VCRCM1805 - DB Name VCRCM suffixed with 18 (for 2018), and 01 (for May) So as you can see if were running the report in May of 2018 we would only need to left join DBs up to April 2018 (i.e. - VCRCM1804). What we need to do is code so that the DB name checks (the suffixes) is performed ahead of the script leveraging in the joins... so the script doesn't error out as May 2018 DB name (VCRCM1805 ) doesn't exist yet. Can someone tell me how to use this code to perform those dynamic checks to see if the DB(s) exist first? %LET OFFSET = -30; DATA _NULL_; CALL SYMPUT('YEAR',PUT(YEAR(INTNX('YEAR',TODAY()&OFFSET.,0)),Z4.)); CALL SYMPUT('MONTH',PUT(MONTH(INTNX('MONTH',TODAY()&OFFSET.,-0)),Z2.)); CALL SYMPUT('YY',PUT(TODAY()&OFFSET.,YEAR2.)); CALL SYMPUT('MM',PUT(MONTH(INTNX('MONTH',TODAY()&OFFSET.,-0)),Z2.)); CALL SYMPUT('DD',PUT(DAY(INTNX('DAY',TODAY()&OFFSET.,-0)),Z2.)); CALL SYMPUT('START_DT',CATS("'",PUT(INTNX('MONTH',TODAY()&OFFSET.,-0,'BEGINNING'),DATE9.),"'D")); CALL SYMPUT('END_DT',CATS("'",PUT(INTNX('MONTH',TODAY()&OFFSET.,0,'END'),DATE9.),"'D")); RUN; %LET DBNME = VPCHM&YY.&MM.; PROC SQL; SELECT COUNT(*) INTO :EXSTTBL FROM DBC.TABLESV WHERE TABLENAME = 'PTY_RB' AND DATABASENAME = "&DBNME."; *************************************************** * IF DEPENDENT TABLE DOES NOT EXIST, EXIT THE JOB ***************************************************; %IF &EXSTTBL. <= 0 %THEN %DO; SOMETHING…..; %END; I'm using SAS EG Version 7.12 HF2 (7.100.2.3386) (32-bit)
... View more