BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Gil_
Quartz | Level 8
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

Id. Date s. m tue. wed thu fri sat
A1. 02/14/19. N. Y. N. Y. Y. N. N
B1. 02/14/19. N. Y. N. Y. N N. N

As you can see A1 02/14/19 is done correctly
And B1 was done on wrong sch date
I would need the ones done on wrong sch day to
Create a different dataset . Its should vary count from 3 to 300 .. thank you for the help
1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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

View solution in original post

8 REPLIES 8
Patrick
Opal | Level 21

"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.

Gil_
Quartz | Level 8
Ok my table looks like this
Id. Date s. m tue. wed thu fri sat
A1. 02/14/19. N. Y. N. Y. Y. N. N
B1. 02/14/19. N. Y. N. Y. N N. N
The date is day of order sun-Sat is the schedule days order should be place. A1 is good since order was done on thur and sch indicates Y on Thur. Im interested only on the ones that had order place but weren't Scheduled like B1
Cynthia_sas
SAS Super FREQ
Hi:
I agree with @Patrick, your question is not clear. In addition, you seem to think that B1 is incorrect, but I don't see what is wrong with B1, if you say that A1 is correct.

Cynthia
Tom
Super User Tom
Super User

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
Gil_
Quartz | Level 8
Thank you Tom will give it a try
Gil_
Quartz | Level 8
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
Reeza
Super User

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

 

Gil_
Quartz | Level 8
Thanks Tom

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 8 replies
  • 1125 views
  • 2 likes
  • 5 in conversation