Problem Note 58532: SAS® Energy Forecasting forecast-instance folders might not be deleted
In SAS Energy Forecasting, when you delete a diagnose instance, the associated forecast-instance folders are not deleted.
Follow these steps to delete the extra folders for the orphaned forecast-instances:
- Place the fcst_cleanup.sas macro in the autocall library that corresponds to your operating system. This macro is located in the Full Code tab of this SAS note.
Windows: C:\Program Files\SASHome\SASFoundation\9.4\enfcsvr\sasmacro
UNIX: SAS94_parent_folder/SAS94/SASHome/SASFoundation/9.4/sasautos
- Start a SAS session.
From a command prompt for Windows, issue these commands:
- cd C:\SAS\Config\Lev1\SASApp
- sas.bat –metauser user name –metapass password
From a command prompt for UNIX, issue these commands:
- cd SAS94 parent folder/SAS94/SASConfig/Lev1/SASApp
- export DISPLAY=ip address
- ./sas.sh –metauser user name -metapass password
- Invoke the macro by running this code:
%fcst_cleanup;
Click the Hot Fix tab in this note to access the hot fix for this issue.
Operating System and Release Information
SAS System | SAS Energy Forecasting | Microsoft® Windows® for x64 | 3.1 | | | |
Linux for x64 | 3.1 | | | |
*
For software releases that are not yet generally available, the Fixed
Release is the software release in which the problem is planned to be
fixed.
Here is the code for the fcst_cleanup.sas macro
%macro fcst_cleanup;
%if %symexist(sef_delim) = 0 %then
%do;
%if &sysscp eq WIN %then
%do;
%let sef_delim = %str(\);
%end;
%else
%do;
%let sef_delim = %str(/);
%end;
%end;
%macro find_fcst_instances(root=);
data instance_dirs (compress=no);
keep time_series_path_nm;
length fref $8 time_series_path_nm filename $120;
rc = filename(fref, "&root");
if rc = 0 then
do;
did = dopen(fref);
rc = filename(fref);
end;
else
do;
length msg $200;
msg = sysmsg();
putlog msg=;
did = .;
end;
if did <= 0 then do;
putlog 'ERROR: Unable to open ' Path=;
return;
end;
dnum = dnum(did); /* Determine # of files/directories in folder. */
do i = 1 to dnum; /* Cycle through all of files/directories. */
filename = dread(did, i);
fid = mopen(did, filename);
/* A return value of 0 from mopen means a directory name. */
if fid = 0 then
do;
/* A directory name was found; calculate the complete */
/* path, and add it to the instance_dirs data set. */
time_series_path_nm = catt("&root", "&sef_delim", filename);
output;
end;
end;
rc = dclose(did);
run;
%mend find_fcst_instances;
%let libref = sasef;
/***************************************************************************************************/
/* Create table containing all forecast definition paths. */
/***************************************************************************************************/
proc sql noprint;
create table forecast_defs as select time_series_path_nm
from &libref..time_series
where definition_flg = "TRUE";
quit;
proc sql noprint;
select count(*) into :rec_cnt
from forecast_defs;
quit;
data all_instance_dirs;
length time_series_path_nm $120;
stop;
run;
%if &rec_cnt > 0 %then %do;
/***************************************************************************************************/
/* Cycle through forecast_defs table adding records to all_instance_dirs table */
/***************************************************************************************************/
%do i = 1 %to &rec_cnt;
data _null_;
set forecast_defs(firstobs=&i obs=&i);
call symput("fcst_def_path_nm", time_series_path_nm);
run;
%find_fcst_instances(root=&fcst_def_path_nm);
proc append base=all_instance_dirs data=instance_dirs;
%end;
%end;
/***************************************************************************************************/
/* Create table containing all orphaned forecast instance folders. */
/***************************************************************************************************/
proc sql noprint;
create table orphaned_fcst_instance_path as select time_series_path_nm
from all_instance_dirs
where time_series_path_nm not in (select time_series_path_nm from &libref..time_series);
quit;
%let rec_cnt = 0 ;
proc sql noprint;
select count(*) into :rec_cnt
from orphaned_fcst_instance_path;
quit;
%if &rec_cnt > 0 %then %do;
/***************************************************************************************************/
/* Cycle through orphaned_fcst_instance_path table deleting paths of the ophaned forecast */
/* instances. */
/***************************************************************************************************/
%do i = 1 %to &rec_cnt;
data _null_;
set orphaned_fcst_instance_path(firstobs=&i obs=&i);
call symput("instance_path", time_series_path_nm);
run;
%sef_delete_dir(path=&instance_path);
%end;
%end;
%mend fcst_cleanup;
In SAS® Energy Forecasting, when you delete a diagnose instance the associated forecast instance folders are not deleted
Type: | Problem Note |
Priority: | medium |
Date Modified: | 2017-01-26 13:00:12 |
Date Created: | 2016-06-29 15:13:00 |