BookmarkSubscribeRSS Feed
me55
Quartz | Level 8

okay, so i need to, as a part of a larger process, check if the date in a field (MONTH) has last months date in it.  if it does it needs to run a series of queries and if it does not, then run other queries.   i am just missing how to figure this out.  i assume to do it, it needs to be run from a macro so something like...

 

%macro datecheck;

%local qry mnthck

%let qry=(proc sql; select max(MONTH) as MNTH from TABLE; quit;);

%let today=%sysfunc(today());

%let lmnth=%sysfunc(intnx(month,&today,-1));

%if &lmnth=&qry %then

%do;

 

list of queries to run...

 

%end;

%mend datecheck;

run;

 

any help?  obviously that does not work but i am also not far off from getting the right answer.  i am just missing the part of getting the query results. 

1 REPLY 1
Kurt_Bremser
Super User
proc sql noprint;
select max(month) into :mnth from table;
quit;

%macro datecheck;
%if %sysfunc(intnx(month,&mnth,0,b)) = %sysfunc(intnx(month,%sysfunc(today()),-1,b))
%then %do; /* last month */
/* some queries */
%end;
%else %do; /* other month */
/* some other queries */
%end;
%mend;
%datecheck

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