Ok. See if the Intnx Function gives you what you want.
data have;
input title $ case sending_date :ddmmyy10.;
format sending_date ddmmyy10.;
datalines;
a 0 27-11-2020
b 0 27-11-2020
c 1 27-11-2020
d 1 02-12-2020
e 1 09-11-2020
f 1 10-11-2020
g 0 13-11-2020
;
data want(drop=case sending_date);
set have;
array d {5} Monday Tuesday Wednesday Thursday Friday;
if intnx('week', today(), 0, 'b') <= sending_date <= intnx('week', today(), 0, 'e') then do;
d[weekday(sending_date) - 1] = sending_date;
output;
end;
format Monday Tuesday Wednesday Thursday Friday ddmmyy10.;
run;
Result:
Obs title Monday Tuesday Wednesday Thursday Friday 1 a . . . . 27/11/2020 2 b . . . . 27/11/2020 3 c . . . . 27/11/2020
Do you only want monday to friday?
Shold we consider the case vairable?
Ok. See if the Intnx Function gives you what you want.
data have;
input title $ case sending_date :ddmmyy10.;
format sending_date ddmmyy10.;
datalines;
a 0 27-11-2020
b 0 27-11-2020
c 1 27-11-2020
d 1 02-12-2020
e 1 09-11-2020
f 1 10-11-2020
g 0 13-11-2020
;
data want(drop=case sending_date);
set have;
array d {5} Monday Tuesday Wednesday Thursday Friday;
if intnx('week', today(), 0, 'b') <= sending_date <= intnx('week', today(), 0, 'e') then do;
d[weekday(sending_date) - 1] = sending_date;
output;
end;
format Monday Tuesday Wednesday Thursday Friday ddmmyy10.;
run;
Result:
Obs title Monday Tuesday Wednesday Thursday Friday 1 a . . . . 27/11/2020 2 b . . . . 27/11/2020 3 c . . . . 27/11/2020
Anytime.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.