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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
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.