04-12-2012 03:56 PM
I have a requirement where I have a dataset which has the days a technician visits a customer.We are only considering weekdays(Mon-Fri).If a technician did not visit the a particular customer
on a weekday then I need to identify that and populate a flag as "NO Visit".Is there any way to achive this based on the below example?
eg: Customer_name TechVist_day
Requirement 1: From the above example I need to populate the flag as "NO Visit" for 04JAN2012 for the customer John and same with customer Sam for 02JAN2012.
Requirement 1 was met through the valuable inputs from LINLIN and ANDREAS_IDS.
Now I need to run the code on a monthly basis and based on the above example,the John's the last record's TechVist_day is 09JAN2012..I need to set the flag for all weekdays after 09JAN2012 till the end of the month(same for Mary 03JAN2012 and SAM 04JAN2012).Please share your thoughts.
04-13-2012 01:58 AM
data have; input Customer_name $ TechVist_day : date9.; format TechVist_day date9.; cards; John 02JAN2012 John 03JAN2012 John 05JAN2012 John 06JAN2012 John 09JAN2012 Mary 02JAN2012 Mary 03JAN2012 Sam 03JAN2012 Sam 04JAN2012 ; run; data want; set have; by Customer_name; output; if last.Customer_name then do; do TechVist_day=TechVist_day+1 to intnx('month',TechVist_day,0,'e'); if weekday(TechVist_day) not in (1 7) then output; end; end; run;