Use the WEEKDAY() function.
data have;
input id $ date (d1-d7) (:$1.);
informat date mmddyy.;
format date yymmdd10. ;
cards;
A1 02/14/19 N Y N Y Y N N
B1 02/14/19 N Y N Y N N N
;
data check;
set have ;
array sched d1-d7 ;
bad = 'Y' ne sched(weekday(date));
run;
Obs id date d1 d2 d3 d4 d5 d6 d7 bad 1 A1 2019-02-14 N Y N Y Y N N 0 2 B1 2019-02-14 N Y N Y N N N 1
"I have a table that derermines orders on off days it looks like this SUN THRU SAT is weekly sch N no orders Y yes order"
I can't make sense of your description. Can you please elaborate/re-formulate.
Use the WEEKDAY() function.
data have;
input id $ date (d1-d7) (:$1.);
informat date mmddyy.;
format date yymmdd10. ;
cards;
A1 02/14/19 N Y N Y Y N N
B1 02/14/19 N Y N Y N N N
;
data check;
set have ;
array sched d1-d7 ;
bad = 'Y' ne sched(weekday(date));
run;
Obs id date d1 d2 d3 d4 d5 d6 d7 bad 1 A1 2019-02-14 N Y N Y Y N N 0 2 B1 2019-02-14 N Y N Y N N N 1
So for the order date, you need to find that day of the week, ie February 14, 2019 is a Thursday, so Thursday should have a Y. Since it doesn't you flag that record?
@Gil_ wrote:
Cynthia
The reason B1 is incorrect is the order was placed on 02/14/19. And per the schedule thur has a N. Which means the order was place on off day
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!
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.
Ready to level-up your skills? Choose your own adventure.