Hello All,
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
John 02JAN2012
John 03JAN2012
John 05JAN2012
John 06JAN2012
John 09JAN2012
Mary 02JAN2012
Mary 03JAN2012
Sam 03JAN2012
Sam 04JAN2012
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.
How about:
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;
Ksharp
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.