23 %MACRO _deletescenariofiles(i_scenariosToRun=
25 %LOCAL l_len l_nobs l_obs l_scnDel l_target l_foldersToDelete l_filesToDelete;
26 %LET l_target = %_abspath(&g_root, &g_target);
29 CREATE TABLE scenarioFilesToDelete AS
31 FROM &i_scenariosToRun AS s
32 WHERE s.dorun = 1 AND scn_id IN (SELECT scn_id FROM target.scn)
34 SELECT scn_id into :l_scnDel separated by
','
35 FROM scenarioFilesToDelete
37 SELECT count(scn_id) AS cnt into :l_obs
38 FROM scenarioFilesToDelete
42 %IF &l_obs GT 0 %THEN %DO;
43 %*** Dir for deletion of /rep, /tst and /log files *;
44 %_dir(i_path=&l_target./rep/, o_out=rep);
45 %_dir(i_path=&l_target./log/, o_out=log);
46 %_dir(i_path=&l_target./tst/, o_out=tst);
48 %let l_filesToDelete = %sysfunc(pathname(work))/_scenarioFilesToDelete.sas;
50 FILE "&l_filesToDelete";
51 SET scenarioFilesToDelete nobs=numobs_dorun;
54 SET log nobs=numobs_log point=i;
55 IF index(membername, put(scn_id,z3.)) = 1 THEN DO;
56 PUT '%PUT Delete ' filename ' RC: %_delfile(' filename ');';
60 SET rep nobs=numobs_rep point=j;
61 IF index(membername, put(scn_id,z3.)) = 1 OR
62 index(membername, catt("_", put(scn_id,z3.))) = 1 OR
63 index(membername, catt("cas_", put(scn_id,z3.),"_")) = 1 OR
64 index(membername, catt("tcg_", put(scn_id,z3.))) = 1
66 PUT '%PUT Delete ' filename ' RC: %_delfile(' filename ');';
70 SET tst nobs=numobs_tst point=k;
71 IF index(membername, put(scn_id,z3.)) = 1 THEN DO;
72 PUT '%PUT Delete ' filename ' RC: %_delfile(' filename ');';
76 %INCLUDE "&l_filesToDelete.";
77 %LET l_rc=%_delfile(&l_filesToDelete.);
79 %*** Deletion of /tst folders ***;
80 %_dir(i_path=&l_target./tst/, i_recursive=1, o_out=tst_folder);
82 %LET l_len = %sysfunc(length(&l_target./tst/));
86 part = substr(filename, &l_len+1);
87 pos = index(part, "/");
89 folder = substr(part, 1, pos-1);
90 id = input(substr(folder,2,3),3.);
91 IF
id IN (&l_scnDel) THEN DO;
98 %LET l_nobs = %_nobs(foldersToDelete);
100 %*** Write and execute cmd file only if table foldersToDelete is not empty ***;
101 %IF &l_nobs > 0 %THEN %DO;
102 PROC SORT DATA = foldersToDelete nodupkey;
106 %let l_foldersToDelete = %sysfunc(pathname(work))/_scenarioFoldersToDelete.cmd;
108 FILE "&l_foldersToDelete";
110 PUT "&g_removedir ""&l_target./tst/" folder+(-1)"""&g_endcommand";
112 %_executeCMDFile(&l_foldersToDelete);
113 %LET l_rc=%_delfile(&l_foldersToDelete);
118 %MEND _deletescenariofiles;