The SAS Output Delivery System and reporting techniques

Macro date logic

Reply
Frequent Contributor
Posts: 90

Macro date logic

Hi All,

We have clamno and other fields in the report. If we are running a program today, it has to get only previous adjudicated date not other date.

For example, if a program runs Monday it has to get the Friday’s data and for Tuesday it has to get Monday’s data vice versa...Do you have any macro code to get only previous day (date format mm/dd/yyyy).

clamno

Adjdate

12345

03/08/2013

56789

03/08/2013

90876

03/29/2013

Output needs to be:

clamno

Adjdate

12345

03/08/2013

56789

03/08/2013

Can you please provide me the sample macro code to get only previous day?

Thanks in Advance

Super User
Posts: 19,861

Re: Macro date logic

%let current_date=%sysfunc(date(), date9.);

%put &current_date;

%let prev_date=%sysfunc(intnx(weekday, "&current_date"d, -1), date9.);

%put &prev_date.;

data want;

set have;

where adjdate="&prev_date"d;

run;

Super Contributor
Posts: 1,636

Re: Macro date logic

an example:

data have;
input clamno adjdate mmddyy10.;
cards;
12345 03/08/2013
56789 03/08/2013
90876 03/29/2013
;
data want;
set have;
if weekday(today())=2 then adate=today()-3;
   else adate=today()-1;
if adjdate=adate;
format adjdate mmddyy10.;
drop adate;
proc print;run;
                                  Obs    clamno       adjdate

                                    1      12345    03/08/2013
                                    2      56789    03/08/2013

Ask a Question
Discussion stats
  • 2 replies
  • 224 views
  • 1 like
  • 3 in conversation