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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 867 views
  • 1 like
  • 3 in conversation