05-07-2013 02:57 PM
Hi I have a data set that looks like this
ID sunship mon ship tue ship wed ship Thursday ship fri ship sat ship. Date ship
7918. 0. 1. 0. 1. 0. 0. 0. 05/01/13
1234. 1. 0. 0. 0. 1. 0. 0. 05/03/13
the ship is date of week there is a shipment Date ship is actual day the ship happen. What I would like is to determine if was ship on correct date for example 05/01/13 was. Correct because it was done on a Wednesday . the 05/03/13 incorrect on wrong day it was on a Friday ....
Thank you again for your assistance
05-07-2013 03:08 PM
how about something like this:
create table work.incorrect_shipment_dates as
not case weekday(date_ship)
when 1 then sunship
when 2 then monship
when 7 then Satship
05-07-2013 05:23 PM
The weekday function in SAS will give you the weekday in 1 to 7.
Then you can check if your shipped day is 1 on that day.
You have two 1s for the 1st one example so not sure how you want to handle that.
array ship(7) sun_ship-sat_ship;
if ship(weekday_shipped)=1 then correct_ship=1;
05-07-2013 10:14 PM
input id ship_sun ship_mon ship_tue ship_wed ship_thu ship_fri ship_sat ship_date mmddyy10.;
format ship_date date9.;
7918 0 0 0 1 0 1 0 05/01/13
1234 1 0 0 0 1 0 0 05/03/13
array weekdays ship_sun--ship_sat;
do over weekdays;
if weekdays=1 then do;
if lowcase(put(ship_date,weekdate3.))=day then yes_ship=day;
Need further help from the community? Please ask a new question.