BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

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 

 

View solution in original post

5 REPLIES 5
PeterClemmensen
Tourmaline | Level 20

Do you only want monday to friday?

 

Shold we consider the case vairable?

SASlearner97
Obsidian | Level 7
i want only monday to friday
the case variable is not important

thank you
PeterClemmensen
Tourmaline | Level 20

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 

 

SASlearner97
Obsidian | Level 7
Thank you so much! it works !