BookmarkSubscribeRSS Feed
raveena
Obsidian | Level 7

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

2 REPLIES 2
Reeza
Super User

%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;

Linlin
Lapis Lazuli | Level 10

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

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1059 views
  • 1 like
  • 3 in conversation