I have a dataset where the first column is based on unique IDs and the second column contains regular monthly dates from 01-31-2016 till 12-31-2017 for each unique ID. Then there are several columns containing some dates (in brackets) and names of managers associated with these dates. I have around 90 columns for Managers and 3500 unique IDs. Below is the sample dataset: Data Have;
infile datalines
dlm=","
missover
DSD;
input ID : $10.
Date_Month : mmddyy10.
Manager1 : $60.
Manager2 : $60.
Manager3 : $60. ;
format Date_Month mmddyy10. ;
datalines;
AB00046,01-31-2016,[2012-01-23 -- ] Ronald Baron,[2016-01-23 -- ] Bill F. Baron,[2016-10-26 -- 2017-06-01] Tim S.
AB00046,02-28-2016,[2012-01-23 -- ] Ronald Baron,[2016-01-23 -- ] Bill F. Baron,[2016-10-26 -- 2017-06-01] Tim S.
AB00046,03-31-2016,[2012-01-23 -- ] Ronald Baron,[2016-01-23 -- ] Bill F. Baron,[2016-10-26 -- 2017-06-01] Tim S.
AB00046,04-30-2016,[2012-01-23 -- ] Ronald Baron,[2016-01-23 -- ] Bill F. Baron,[2016-10-26 -- 2017-06-01] Tim S.
AB00046,05-31-2016,[2012-01-23 -- ] Ronald Baron,[2016-01-23 -- ] Bill F. Baron,[2016-10-26 -- 2017-06-01] Tim S.
AB00046,06-30-2016,[2012-01-23 -- ] Ronald Baron,[2016-01-23 -- ] Bill F. Baron,[2016-10-26 -- 2017-06-01] Tim S.
AB00046,07-31-2016,[2012-01-23 -- ] Ronald Baron,[2016-01-23 -- ] Bill F. Baron,[2016-10-26 -- 2017-06-01] Tim S.
AB00046,08-31-2016,[2012-01-23 -- ] Ronald Baron,[2016-01-23 -- ] Bill F. Baron,[2016-10-26 -- 2017-06-01] Tim S.
AB00046,09-30-2016,[2012-01-23 -- ] Ronald Baron,[2016-01-23 -- ] Bill F. Baron,[2016-10-26 -- 2017-06-01] Tim S.
AB00046,10-31-2016,[2012-01-23 -- ] Ronald Baron,[2016-01-23 -- ] Bill F. Baron,[2016-10-26 -- 2017-06-01] Tim S.
AB00046,11-30-2016,[2012-01-23 -- ] Ronald Baron,[2016-01-23 -- ] Bill F. Baron,[2016-10-26 -- 2017-06-01] Tim S.
AB00046,12-31-2016,[2012-01-23 -- ] Ronald Baron,[2016-01-23 -- ] Bill F. Baron,[2016-10-26 -- 2017-06-01] Tim S.
AB00046,01-31-2017,[2012-01-23 -- ] Ronald Baron,[2016-01-23 -- ] Bill F. Baron,[2016-10-26 -- 2017-06-01] Tim S.
AB00046,02-28-2017,[2012-01-23 -- ] Ronald Baron,[2016-01-23 -- ] Bill F. Baron,[2016-10-26 -- 2017-06-01] Tim S.
AB00046,03-31-2017,[2012-01-23 -- ] Ronald Baron,[2016-01-23 -- ] Bill F. Baron,[2016-10-26 -- 2017-06-01] Tim S.
AB00046,04-30-2017,[2012-01-23 -- ] Ronald Baron,[2016-01-23 -- ] Bill F. Baron,[2016-10-26 -- 2017-06-01] Tim S.
AB00046,05-31-2017,[2012-01-23 -- ] Ronald Baron,[2016-01-23 -- ] Bill F. Baron,[2016-10-26 -- 2017-06-01] Tim S.
AB00046,06-30-2017,[2012-01-23 -- ] Ronald Baron,[2016-01-23 -- ] Bill F. Baron,[2016-10-26 -- 2017-06-01] Tim S.
AB00046,07-31-2017,[2012-01-23 -- ] Ronald Baron,[2016-01-23 -- ] Bill F. Baron,[2016-10-26 -- 2017-06-01] Tim S.
AB00046,08-31-2017,[2012-01-23 -- ] Ronald Baron,[2016-01-23 -- ] Bill F. Baron,[2016-10-26 -- 2017-06-01] Tim S.
AB00046,09-30-2017,[2012-01-23 -- ] Ronald Baron,[2016-01-23 -- ] Bill F. Baron,[2016-10-26 -- 2017-06-01] Tim S.
AB00046,10-31-2017,[2012-01-23 -- ] Ronald Baron,[2016-01-23 -- ] Bill F. Baron,[2016-10-26 -- 2017-06-01] Tim S.
AB00046,11-30-2017,[2012-01-23 -- ] Ronald Baron,[2016-01-23 -- ] Bill F. Baron,[2016-10-26 -- 2017-06-01] Tim S.
AB00046,12-31-2017,[2012-01-23 -- ] Ronald Baron,[2016-01-23 -- ] Bill F. Baron,[2016-10-26 -- 2017-06-01] Tim S.
AB00050,01-31-2016,[2010-05-20 -- 2014-01-02] Tom T.,[2016-06-29 -- 2018-06-06] Sharon,
AB00050,02-28-2016,[2010-05-20 -- 2014-01-02] Tom T.,[2016-06-29 -- 2018-06-06] Sharon,
AB00050,03-31-2016,[2010-05-20 -- 2014-01-02] Tom T.,[2016-06-29 -- 2018-06-06] Sharon,
AB00050,04-30-2016,[2010-05-20 -- 2014-01-02] Tom T.,[2016-06-29 -- 2018-06-06] Sharon,
AB00050,05-31-2016,[2010-05-20 -- 2014-01-02] Tom T.,[2016-06-29 -- 2018-06-06] Sharon,
AB00050,06-30-2016,[2010-05-20 -- 2014-01-02] Tom T.,[2016-06-29 -- 2018-06-06] Sharon,
AB00050,07-31-2016,[2010-05-20 -- 2014-01-02] Tom T.,[2016-06-29 -- 2018-06-06] Sharon,
AB00050,08-31-2016,[2010-05-20 -- 2014-01-02] Tom T.,[2016-06-29 -- 2018-06-06] Sharon,
AB00050,09-30-2016,[2010-05-20 -- 2014-01-02] Tom T.,[2016-06-29 -- 2018-06-06] Sharon,
AB00050,10-31-2016,[2010-05-20 -- 2014-01-02] Tom T.,[2016-06-29 -- 2018-06-06] Sharon,
AB00050,11-30-2016,[2010-05-20 -- 2014-01-02] Tom T.,[2016-06-29 -- 2018-06-06] Sharon,
AB00050,12-31-2016,[2010-05-20 -- 2014-01-02] Tom T.,[2016-06-29 -- 2018-06-06] Sharon,
AB00050,01-31-2017,[2010-05-20 -- 2014-01-02] Tom T.,[2016-06-29 -- 2018-06-06] Sharon,
AB00050,02-28-2017,[2010-05-20 -- 2014-01-02] Tom T.,[2016-06-29 -- 2018-06-06] Sharon,
AB00050,03-31-2017,[2010-05-20 -- 2014-01-02] Tom T.,[2016-06-29 -- 2018-06-06] Sharon,
AB00050,04-30-2017,[2010-05-20 -- 2014-01-02] Tom T.,[2016-06-29 -- 2018-06-06] Sharon,
AB00050,05-31-2017,[2010-05-20 -- 2014-01-02] Tom T.,[2016-06-29 -- 2018-06-06] Sharon,
AB00050,06-30-2017,[2010-05-20 -- 2014-01-02] Tom T.,[2016-06-29 -- 2018-06-06] Sharon,
AB00050,07-31-2017,[2010-05-20 -- 2014-01-02] Tom T.,[2016-06-29 -- 2018-06-06] Sharon,
AB00050,08-31-2017,[2010-05-20 -- 2014-01-02] Tom T.,[2016-06-29 -- 2018-06-06] Sharon,
AB00050,09-30-2017,[2010-05-20 -- 2014-01-02] Tom T.,[2016-06-29 -- 2018-06-06] Sharon,
AB00050,10-31-2017,[2010-05-20 -- 2014-01-02] Tom T.,[2016-06-29 -- 2018-06-06] Sharon,
AB00050,11-30-2017,[2010-05-20 -- 2014-01-02] Tom T.,[2016-06-29 -- 2018-06-06] Sharon,
AB00050,12-31-2017,[2010-05-20 -- 2014-01-02] Tom T.,[2016-06-29 -- 2018-06-06] Sharon,
;
run; I want the following: 1- In all the columns where bracket dates' "year" and "month" match with the "year" and "month" of Date_month column, keep the names of managers. The bracket of dates should not be displayed in "want" dataset. 2- If the starting date in the bracket is earlier than the starting date of Date_month column i.e. 01-31-2016, then manager's name should start from 01-31-2016, all previous dates in the bracket must be ignored. 3- If the ending date in the bracket is either greater than the ending date of Date_month column i.e. 12-31-2017 or is not given and shown as dashes e.g. [2016-01-23 -- ], then manager name must be continued till 12-31-2017. 4- When month and year of these two dates are not matched, such manager's name must be ignored. Please see below the required output dataset: Data Want;
infile datalines
dlm=","
missover
DSD;
input ID : $10.
Date_Month : mmddyy10.
Manager1 : $60.
Manager2 : $60.
Manager3 : $60. ;
format Date_Month mmddyy10. ;
datalines;
AB00046,01-31-2016,Ronald Baron,Bill F. Baron,
AB00046,02-28-2016,Ronald Baron,Bill F. Baron,
AB00046,03-31-2016,Ronald Baron,Bill F. Baron,
AB00046,04-30-2016,Ronald Baron,Bill F. Baron,
AB00046,05-31-2016,Ronald Baron,Bill F. Baron,
AB00046,06-30-2016,Ronald Baron,Bill F. Baron,
AB00046,07-31-2016,Ronald Baron,Bill F. Baron,
AB00046,08-31-2016,Ronald Baron,Bill F. Baron,
AB00046,09-30-2016,Ronald Baron,Bill F. Baron,
AB00046,10-31-2016,Ronald Baron,Bill F. Baron,Tim S.
AB00046,11-30-2016,Ronald Baron,Bill F. Baron,Tim S.
AB00046,12-31-2016,Ronald Baron,Bill F. Baron,Tim S.
AB00046,01-31-2017,Ronald Baron,Bill F. Baron,Tim S.
AB00046,02-28-2017,Ronald Baron,Bill F. Baron,Tim S.
AB00046,03-31-2017,Ronald Baron,Bill F. Baron,Tim S.
AB00046,04-30-2017,Ronald Baron,Bill F. Baron,Tim S.
AB00046,05-31-2017,Ronald Baron,Bill F. Baron,Tim S.
AB00046,06-30-2017,Ronald Baron,Bill F. Baron,Tim S.
AB00046,07-31-2017,Ronald Baron,Bill F. Baron,
AB00046,08-31-2017,Ronald Baron,Bill F. Baron,
AB00046,09-30-2017,Ronald Baron,Bill F. Baron,
AB00046,10-31-2017,Ronald Baron,Bill F. Baron,
AB00046,11-30-2017,Ronald Baron,Bill F. Baron,
AB00046,12-31-2017,Ronald Baron,Bill F. Baron,
AB00050,01-31-2016,
AB00050,02-28-2016,
AB00050,03-31-2016,
AB00050,04-30-2016,
AB00050,05-31-2016,
AB00050,06-30-2016,Sharon
AB00050,07-31-2016,Sharon
AB00050,08-31-2016,Sharon
AB00050,09-30-2016,Sharon
AB00050,10-31-2016,Sharon
AB00050,11-30-2016,Sharon
AB00050,12-31-2016,Sharon
AB00050,01-31-2017,Sharon
AB00050,02-28-2017,Sharon
AB00050,03-31-2017,Sharon
AB00050,04-30-2017,Sharon
AB00050,05-31-2017,Sharon
AB00050,06-30-2017,Sharon
AB00050,07-31-2017,Sharon
AB00050,08-31-2017,Sharon
AB00050,09-30-2017,Sharon
AB00050,10-31-2017,Sharon
AB00050,11-30-2017,Sharon
AB00050,12-31-2017,Sharon
;
run; Please suggest some solution. Thanks.
... View more