Dear All, For the attached tab-delimited file I need to determine the process flow of the active processes. To identify the active process the condition is missing(datef)=1. For example Process 682 is active and it comes from 634. BUT 632 is opened and closed in the current month (datas_ini = 2JAN2015 and datef_ini=5JAN2015). Therefore we have to look back at 632 and determine where it comes from. 632 comes from 447, 510, 559. BUT since 510 is opened and closed in the current month it is ignored. Eventually the correct result is 682-447 and 682-559. The code I have build does not work for all the cases. Let's take process no 9. 9 comes from 7. BUT 7 is opened and closed in the current month. Looking back at 7 we see that 7 comes from 3, 5, 6. Since 3 is closed we look back at it and notice that 3 comes from 4. 4 is closed - we look back at it and we notice that 4 comes from 44. Therefore 7 comes from 44. BUT 7 also comes from 5 and 6 since those processes are active. Unfortunately the codes does not write to output - 7-44, 7-5 and 7-6. It only writes 7-44. The correspondence of the variables is ky-process-datef-datas and ky_ini_ini-process_ini-datef_ini-datas_ini. Here is my code: %let &data_lun_ant="31DEC2015"d; data want ; length ky_ini_hsh $ 30; if 0 then set have; if _n_ eq 1 then do; CALL MISSING(process_ini_hsh,datas_ini_hsh,datef_ini_hsh); call missing(ky_ini_hsh); declare hash ir(dataset:"have(rename=(process_ini=process_ini_hsh datas_ini=datas_ini_hsh datef_ini=datef_ini_hsh ky_ini=ky_ini_hsh ) where=(datas gt &data_lun_ant and datef gt &data_lun_ant))", multidata:'Y'); ir.definekey('ky'); ir.definedata('process_ini_hsh','datas_ini_hsh', 'datef_ini_hsh', 'ky_ini_hsh'); ir.definedone(); end; set have(where=(missing(datef)=1)); if datas_ini gt &data_lun_ant and datef_ini gt &data_lun_ant then do; rc=ir.find(key:ky_ini); do while (rc=0); if datas_ini_hsh gt &data_lun_ant and datef_ini_hsh gt &data_lun_ant then do; _ky_ini_hsh=ky_ini_hsh; _ky_ini=ky_ini; rc1=ir.find_next(key:_ky_ini); rc=ir.find(key:_ky_ini_hsh); if rc1=0 then rc=0; end; else do; conne=catx('-',process,process_ini_hsh); output; rc=ir.find_next(key:ky_ini); end; end; end; else do;conne=catx('-',process,process_ini);output;end; run;
... View more