BookmarkSubscribeRSS Feed
chennupriya
Quartz | Level 8

automate date in oracle pass through query using intnx instead of hard code

2 REPLIES 2
AbhiD
Obsidian | Level 7

Hi,

Please could you elobrate ur issue with an example

 

Rgds,
Abhi

dcruik
Lapis Lazuli | Level 10

You may want to be more specific as far as what you want the macro variable to do or be equal to, but here's a brief example using 10 days ago from the current date (this is assuming your Date Variable in the Oracle Table is Date and not DateTime):

 

%let today=%sysfunc(today(),date9.);
%let date=%sysfunc(intnx(DAY,"&today"d,-10),date9.);
%put *** Today Macro = &today AND Date Macro = &date ***;

proc sql;
connect to oracle (/*database options*/);
create table want as select * from connection to oracle
	(select *
	 from /*name of table*/
	 where /*name of date variable*/>="&date"d);
quit;

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
  • 2 replies
  • 1075 views
  • 0 likes
  • 3 in conversation