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.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.