BACKGROUND
I have a script that runs every month creating the dataset to be used by my team. The script generates datasets in my personal UNIX directory, I then run sanity checks and copy the dataset to a "public" directory where my team can access it. The script is stable so there is no need to run sanity checks anymore.
WHAT I WANT TO DO
- Extract the last modified date from previous version of the dataset from the public folder (Working fine)
- Upend the previous dataset name with modified date (facing issues)
- Move/copy the newly created dataset to public folder (Working fine)
PROBLEM STATEMENT
I am getting following error while attempting to change the dataset name
ERROR: You cannot rename COSTDATA.EMPL_CHAIN.DATA to COSTDATA.EMPL_CHAIN_19SEP18.DATA because COSTDATA.EMPL_CHAIN.DATA is in use by you in resource environment IOM ROOT COMP ENV.
CODE USED
%let dsid2=%sysfunc(open(costdata.empl_chain));
%put ********&dsid2;
%let modte2=%sysfunc(attrn(&dsid2,modte),datetime7.);
%put &modte2;
%let rc=%sysfunc(close(&dsid2));
%put RC Value is &rc;
proc datasets library=costdata;
change empl_chain=empl_chain_&modte2;
run;
SAS LOG
29 %let dsid2=%sysfunc(open(costdata.empl_chain));
30 %put ********&dsid2;
********2
31 %let modte2=%sysfunc(attrn(&dsid2,modte),datetime7.);
32 %put &modte2;
19SEP18
33 %let rc=%sysfunc(close(&dsid2));
34 %put RC Value is &rc;
RC Value is 0
35
36 proc datasets library=costdata;
37 change empl_chain=empl_chain_&modte2;
38 run;
NOTE: Changing the name COSTDATA.EMPL_CHAIN to COSTDATA.EMPL_CHAIN_19SEP18 (memtype=DATA).
ERROR: You cannot rename COSTDATA.EMPL_CHAIN.DATA to COSTDATA.EMPL_CHAIN_19SEP18.DATA because COSTDATA.EMPL_CHAIN.DATA is in use by you in resource environment IOM ROOT COMP ENV.
39
Other helpful information:
I am trying to do the similar operation to multiple datasets. The rename piece works fine for the first dataset if the SAS EG session is new. It predictably fails for second dataset onward. In EG, Tools > Options > Data > Data General... the 'Automatically open data when added to project' checkbox is Unchecked as suggested by SAS.
I am also aware of other simple tricks such as declaring a new dataset with correct name in a new data step or using 'exchange' function in proc dataset. I would like to know however, if there is any solution to the above error.